Index  Source Files  Annotated Class List  Alphabetical Class List  Class Hierarchy  Graphical Class Hierarchy   
 

FIX::FileLog Class Reference

File based implementation of Log. More...

#include <FileLog.h>

Inheritance diagram for FIX::FileLog:

Inheritance graph
[legend]
Collaboration diagram for FIX::FileLog:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FileLog (const std::string &path)
 FileLog (const std::string &path, const SessionID &sessionID)
virtual ~FileLog ()
void clear ()
void onIncoming (const std::string &value)
void onOutgoing (const std::string &value)
void onEvent (const std::string &value)

Private Member Functions

void init (std::string path, const std::string &prefix)

Private Attributes

std::ofstream m_messages
std::ofstream m_event
std::string m_messagesFileName
std::string m_eventFileName

Detailed Description

File based implementation of Log.

Three files are created by this implementation. One for outgoing messages, one for incoming message, and one for events.

The formats of the files are:
   [path]+[BeginString]-[SenderCompID]-[TargetCompID].messages
   [path]+[BeginString]-[SenderCompID]-[TargetCompID].event

Definition at line 73 of file FileLog.h.


Constructor & Destructor Documentation

FIX::FileLog::FileLog const std::string &  path  ) 
 

Definition at line 86 of file FileLog.cpp.

References init().

00087 {
00088   init( path, "GLOBAL" );
00089 }

FIX::FileLog::FileLog const std::string &  path,
const SessionID sessionID
 

Definition at line 91 of file FileLog.cpp.

References FIX::SessionID::getBeginString(), FIX::SessionID::getSenderCompID(), FIX::SessionID::getSessionQualifier(), FIX::SessionID::getTargetCompID(), and init().

00092 {
00093   const std::string& begin =
00094     s.getBeginString().getString();
00095   const std::string& sender =
00096     s.getSenderCompID().getString();
00097   const std::string& target =
00098     s.getTargetCompID().getString();
00099   const std::string& qualifier =
00100     s.getSessionQualifier();
00101 
00102   std::string prefix = begin + "-" + sender + "-" + target;
00103   if( qualifier.size() )
00104     prefix += "-" + qualifier;
00105 
00106   init( path, prefix );
00107 }

FIX::FileLog::~FileLog  )  [virtual]
 

Definition at line 130 of file FileLog.cpp.

00131 {
00132   m_messages.close();
00133   m_event.close();
00134 }


Member Function Documentation

void FIX::FileLog::clear  )  [virtual]
 

Implements FIX::Log.

Definition at line 136 of file FileLog.cpp.

References m_eventFileName, and m_messagesFileName.

00137 {
00138   m_messages.close();
00139   m_event.close();
00140 
00141   m_messages.open( m_messagesFileName.c_str(), std::ios::out | std::ios::trunc );
00142   m_event.open( m_eventFileName.c_str(), std::ios::out | std::ios::trunc );
00143 }

void FIX::FileLog::init std::string  path,
const std::string &  prefix
[private]
 

Definition at line 109 of file FileLog.cpp.

References FIX::file_appendpath(), FIX::file_mkdir(), m_eventFileName, m_messagesFileName, QF_STACK_POP, and QF_STACK_PUSH.

Referenced by FileLog().

00110 { QF_STACK_PUSH(FileLog::init)
00111         
00112   file_mkdir( path.c_str() );
00113 
00114   if ( path.empty() ) path = ".";
00115 
00116   std::string fullPrefix
00117     = file_appendpath(path, prefix + ".");
00118 
00119   m_messagesFileName = fullPrefix + "messages.log";
00120   m_eventFileName = fullPrefix + "event.log";
00121 
00122   m_messages.open( m_messagesFileName.c_str(), std::ios::out | std::ios::app );
00123   if ( !m_messages.is_open() ) throw ConfigError( "Could not open messages file" );
00124   m_event.open( m_eventFileName.c_str(), std::ios::out | std::ios::app );
00125   if ( !m_event.is_open() ) throw ConfigError( "Could not open event file" );
00126 
00127   QF_STACK_POP
00128 }

void FIX::FileLog::onEvent const std::string &  value  )  [inline, virtual]
 

Implements FIX::Log.

Definition at line 86 of file FileLog.h.

00087   {
00088     UtcTimeStamp now;
00089     m_event << UtcTimeStampConvertor::convert( now )
00090     << " : " << value << std::endl << std::flush;
00091   }

void FIX::FileLog::onIncoming const std::string &  value  )  [inline, virtual]
 

Implements FIX::Log.

Definition at line 82 of file FileLog.h.

00083   { m_messages << value << std::endl << std::flush; }

void FIX::FileLog::onOutgoing const std::string &  value  )  [inline, virtual]
 

Implements FIX::Log.

Definition at line 84 of file FileLog.h.

00085   { m_messages << value << std::endl << std::flush; }


Member Data Documentation

std::ofstream FIX::FileLog::m_event [private]
 

Definition at line 97 of file FileLog.h.

std::string FIX::FileLog::m_eventFileName [private]
 

Definition at line 99 of file FileLog.h.

Referenced by clear(), and init().

std::ofstream FIX::FileLog::m_messages [private]
 

Definition at line 96 of file FileLog.h.

std::string FIX::FileLog::m_messagesFileName [private]
 

Definition at line 98 of file FileLog.h.

Referenced by clear(), and init().


The documentation for this class was generated from the following files:
Generated on Mon Jul 24 19:36:44 2006 for QuickFIX by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2001