QuickFIX: FIX::FileLog Class Reference

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:
[legend]
Collaboration diagram for FIX::FileLog:
[legend]

List of all members.

## Public Member Functions
| FileLog (const std::string &path)
| FileLog (const std::string &path, const SessionID &sessionID)
| FileLog (const std::string &path, const std::string &backupPath, const SessionID &sessionID)
virtual | ~FileLog ()
void | clear ()
void | backup ()
void | onIncoming (const std::string &value)
void | onOutgoing (const std::string &value)
void | onEvent (const std::string &value)
bool | getMillisecondsInTimeStamp () const
void | setMillisecondsInTimeStamp (bool value)
## Private Member Functions
std::string | generatePrefix (const SessionID &sessionID)
void | init (std::string path, std::string backupPath, const std::string &prefix)
## Private Attributes
std::ofstream | m_messages
std::ofstream | m_event
std::string | m_messagesFileName
std::string | m_eventFileName
std::string | m_fullPrefix
std::string | m_fullBackupPrefix
bool | m_millisecondsInTimeStamp

## Detailed Description

File based implementation of Log.

Two files are created by this implementation. One for messages, and one for events.

Definition at line 70 of file FileLog.h.

## Constructor & Destructor Documentation

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

Definition at line 96 of file FileLog.cpp.

References init().

    00097 : m_millisecondsInTimeStamp( true )
    00098 {
    00099   init( path, path, "GLOBAL" );
    00100 }

FIX::FileLog::FileLog | ( | const std::string & | path,
|  | const SessionID & | sessionID |
| ) |  |  |

Definition at line 102 of file FileLog.cpp.

References generatePrefix(), and init().

    00103 : m_millisecondsInTimeStamp( true )
    00104 {
    00105   init( path, path, generatePrefix(s) );
    00106 }

FIX::FileLog::FileLog | ( | const std::string & | path,
|  | const std::string & | backupPath,
|  | const SessionID & | sessionID |
| ) |  |  |

Definition at line 108 of file FileLog.cpp.

References generatePrefix(), and init().

    00109 : m_millisecondsInTimeStamp( true )
    00110 {
    00111   init( path, backupPath, generatePrefix(s) );
    00112 }

FIX::FileLog::~FileLog | ( |  | ) | `[virtual]`

Definition at line 157 of file FileLog.cpp.

References m_event, and m_messages.

    00158 {
    00159   m_messages.close();
    00160   m_event.close();
    00161 }

## Member Function Documentation

void FIX::FileLog::backup | ( |  | ) | `[virtual]`

Implements FIX::Log.

Definition at line 172 of file FileLog.cpp.

References FIX::file_fclose(), FIX::file_fopen(), FIX::file_rename(), m_event, m_eventFileName, m_fullBackupPrefix, m_messages, and m_messagesFileName.

    00173 {
    00174   m_messages.close();
    00175   m_event.close();
    00176
    00177   int i = 0;
    00178   while( true )
    00179   {
    00180     std::stringstream messagesFileName;
    00181     std::stringstream eventFileName;
    00182
    00183     messagesFileName << m_fullBackupPrefix << "messages.backup." << ++i << ".log";
    00184     eventFileName << m_fullBackupPrefix << "event.backup." << i << ".log";
    00185     FILE* messagesLogFile = file_fopen( messagesFileName.str().c_str(), "r" );
    00186     FILE* eventLogFile = file_fopen( eventFileName.str().c_str(), "r" );
    00187
    00188     if( messagesLogFile == NULL && eventLogFile == NULL )
    00189     {
    00190       file_rename( m_messagesFileName.c_str(), messagesFileName.str().c_str() );
    00191       file_rename( m_eventFileName.c_str(), eventFileName.str().c_str() );
    00192       m_messages.open( m_messagesFileName.c_str(), std::ios::out | std::ios::trunc );
    00193       m_event.open( m_eventFileName.c_str(), std::ios::out | std::ios::trunc );
    00194       return;
    00195     }
    00196
    00197     if( messagesLogFile != NULL ) file_fclose( messagesLogFile );
    00198     if( eventLogFile != NULL ) file_fclose( eventLogFile );
    00199   }
    00200 }

void FIX::FileLog::clear | ( |  | ) | `[virtual]`

Implements FIX::Log.

Definition at line 163 of file FileLog.cpp.

References m_event, m_eventFileName, m_messages, and m_messagesFileName.

    00164 {
    00165   m_messages.close();
    00166   m_event.close();
    00167
    00168   m_messages.open( m_messagesFileName.c_str(), std::ios::out | std::ios::trunc );
    00169   m_event.open( m_eventFileName.c_str(), std::ios::out | std::ios::trunc );
    00170 }

std::string FIX::FileLog::generatePrefix | ( | const SessionID & | sessionID | ) | `[private]`

Definition at line 114 of file FileLog.cpp.

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

Referenced by FileLog().

    00115 {
    00116   const std::string& begin =
    00117     s.getBeginString().getString();
    00118   const std::string& sender =
    00119     s.getSenderCompID().getString();
    00120   const std::string& target =
    00121     s.getTargetCompID().getString();
    00122   const std::string& qualifier =
    00123     s.getSessionQualifier();
    00124
    00125   std::string prefix = begin + "-" + sender + "-" + target;
    00126   if( qualifier.size() )
    00127     prefix += "-" + qualifier;
    00128
    00129   return prefix;
    00130 }

bool FIX::FileLog::getMillisecondsInTimeStamp | ( |  | ) | const`[inline]`

Definition at line 92 of file FileLog.h.

References m_millisecondsInTimeStamp.

    00093   { return m_millisecondsInTimeStamp; }

void FIX::FileLog::init | ( | std::string | path,
|  | std::string | backupPath,
|  | const std::string & | prefix |
| ) |  |  | `[private]`

Definition at line 132 of file FileLog.cpp.

References FIX::file_appendpath(), FIX::file_mkdir(), m_event, m_eventFileName, m_fullBackupPrefix, m_fullPrefix, m_messages, m_messagesFileName, QF_STACK_POP, and QF_STACK_PUSH.

Referenced by FileLog().

    00133 { QF_STACK_PUSH(FileLog::init)
    00134
    00135   file_mkdir( path.c_str() );
    00136   file_mkdir( backupPath.c_str() );
    00137
    00138   if ( path.empty() ) path = ".";
    00139   if ( backupPath.empty() ) backupPath = path;
    00140
    00141   m_fullPrefix
    00142     = file_appendpath(path, prefix + ".");
    00143   m_fullBackupPrefix
    00144     = file_appendpath(backupPath, prefix + ".");
    00145
    00146   m_messagesFileName = m_fullPrefix + "messages.current.log";
    00147   m_eventFileName = m_fullPrefix + "event.current.log";
    00148
    00149   m_messages.open( m_messagesFileName.c_str(), std::ios::out | std::ios::app );
    00150   if ( !m_messages.is_open() ) throw ConfigError( "Could not open messages file: " + m_messagesFileName );
    00151   m_event.open( m_eventFileName.c_str(), std::ios::out | std::ios::app );
    00152   if ( !m_event.is_open() ) throw ConfigError( "Could not open event file: " + m_eventFileName );
    00153
    00154   QF_STACK_POP
    00155 }

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

Implements FIX::Log.

Definition at line 85 of file FileLog.h.

References FIX::UtcTimeStampConvertor::convert(), m_event, and m_millisecondsInTimeStamp.

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

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

Implements FIX::Log.

Definition at line 81 of file FileLog.h.

References FIX::UtcTimeStampConvertor::convert(), m_messages, m_millisecondsInTimeStamp, and FIX::TYPE::UtcTimeStamp.

    00082   { m_messages << UtcTimeStampConvertor::convert(UtcTimeStamp(), m_millisecondsInTimeStamp) << " : " << value << std::endl; }

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

Implements FIX::Log.

Definition at line 83 of file FileLog.h.

References FIX::UtcTimeStampConvertor::convert(), m_messages, m_millisecondsInTimeStamp, and FIX::TYPE::UtcTimeStamp.

    00084   { m_messages << UtcTimeStampConvertor::convert(UtcTimeStamp(), m_millisecondsInTimeStamp) << " : " << value << std::endl; }

void FIX::FileLog::setMillisecondsInTimeStamp | ( | bool | value | ) | `[inline]`

Definition at line 94 of file FileLog.h.

References m_millisecondsInTimeStamp.

    00095   { m_millisecondsInTimeStamp = value; }

## Member Data Documentation

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

Definition at line 102 of file FileLog.h.

Referenced by backup(), clear(), init(), onEvent(), and ~FileLog().

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

Definition at line 104 of file FileLog.h.

Referenced by backup(), clear(), and init().

std::string FIX::FileLog::m_fullBackupPrefix`[private]`

Definition at line 106 of file FileLog.h.

Referenced by backup(), and init().

std::string FIX::FileLog::m_fullPrefix`[private]`

Definition at line 105 of file FileLog.h.

Referenced by init().

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

Definition at line 101 of file FileLog.h.

Referenced by backup(), clear(), init(), onIncoming(), onOutgoing(), and ~FileLog().

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

Definition at line 103 of file FileLog.h.

Referenced by backup(), clear(), and init().

bool FIX::FileLog::m_millisecondsInTimeStamp`[private]`

Definition at line 107 of file FileLog.h.

Referenced by getMillisecondsInTimeStamp(), onEvent(), onIncoming(), onOutgoing(), and setMillisecondsInTimeStamp().

The documentation for this class was generated from the following files:

- /home/omiller/Development/autobuild/quickfix/src/C++/FileLog.h
- /home/omiller/Development/autobuild/quickfix/src/C++/FileLog.cpp