Public Member Functions | Private Member Functions | Private Attributes | List of all members
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]

Public Member Functions

 FileLog (const std::string &path)
 
 FileLog (const std::string &path, const std::string &backupPath)
 
 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)
 
- Public Member Functions inherited from FIX::Log
virtual ~Log ()
 

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
 

Detailed Description

File based implementation of Log.

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

Definition at line 87 of file FileLog.h.

Constructor & Destructor Documentation

◆ FileLog() [1/4]

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

Definition at line 108 of file FileLog.cpp.

112 {

◆ FileLog() [2/4]

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

Definition at line 113 of file FileLog.cpp.

◆ FileLog() [3/4]

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

Definition at line 118 of file FileLog.cpp.

◆ FileLog() [4/4]

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

Definition at line 123 of file FileLog.cpp.

◆ ~FileLog()

FIX::FileLog::~FileLog ( )
virtual

Definition at line 168 of file FileLog.cpp.

173  {

Member Function Documentation

◆ backup()

void FIX::FileLog::backup ( )
virtual

Implements FIX::Log.

Definition at line 183 of file FileLog.cpp.

183  {
184  file_rename( m_messagesFileName.c_str(), messagesFileName.str().c_str() );
185  file_rename( m_eventFileName.c_str(), eventFileName.str().c_str() );
186  m_messages.open( m_messagesFileName.c_str(), std::ios::out | std::ios::trunc );
187  m_event.open( m_eventFileName.c_str(), std::ios::out | std::ios::trunc );
188  return;
189  }
190 
191  if( messagesLogFile != NULL ) file_fclose( messagesLogFile );
192  if( eventLogFile != NULL ) file_fclose( eventLogFile );
193  }
194 }
195 
196 } //namespace FIX

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

◆ clear()

void FIX::FileLog::clear ( )
virtual

Implements FIX::Log.

Definition at line 174 of file FileLog.cpp.

183  {

◆ generatePrefix()

std::string FIX::FileLog::generatePrefix ( const SessionID sessionID)
private

Definition at line 128 of file FileLog.cpp.

130 {
131  file_mkdir( path.c_str() );
132  file_mkdir( backupPath.c_str() );
133 
134  if ( path.empty() ) path = ".";
135  if ( backupPath.empty() ) backupPath = path;
136 
138  = file_appendpath(path, prefix + ".");
140  = file_appendpath(backupPath, prefix + ".");
141 
142  m_messagesFileName = m_fullPrefix + "messages.current.log";
143  m_eventFileName = m_fullPrefix + "event.current.log";
144 

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

◆ init()

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

Definition at line 146 of file FileLog.cpp.

146  : " + m_messagesFileName );
147  m_event.open( m_eventFileName.c_str(), std::ios::out | std::ios::app );
148  if ( !m_event.is_open() ) throw ConfigError( "Could not open event file: " + m_eventFileName );
149 }
150 
151 FileLog::~FileLog()
152 {
153  m_messages.close();
154  m_event.close();
155 }
156 
157 void FileLog::clear()
158 {
159  m_messages.close();
160  m_event.close();
161 
162  m_messages.open( m_messagesFileName.c_str(), std::ios::out | std::ios::trunc );
163  m_event.open( m_eventFileName.c_str(), std::ios::out | std::ios::trunc );
164 }
165 
166 void FileLog::backup()

Referenced by FIX::FileLogFactory::destroy().

◆ onEvent()

void FIX::FileLog::onEvent ( const std::string &  value)
inlinevirtual

Implements FIX::Log.

Definition at line 103 of file FileLog.h.

◆ onIncoming()

void FIX::FileLog::onIncoming ( const std::string &  value)
inlinevirtual

Implements FIX::Log.

Definition at line 99 of file FileLog.h.

◆ onOutgoing()

void FIX::FileLog::onOutgoing ( const std::string &  value)
inlinevirtual

Implements FIX::Log.

Definition at line 101 of file FileLog.h.

Member Data Documentation

◆ m_event

std::ofstream FIX::FileLog::m_event
private

Definition at line 115 of file FileLog.h.

Referenced by backup().

◆ m_eventFileName

std::string FIX::FileLog::m_eventFileName
private

Definition at line 117 of file FileLog.h.

Referenced by backup(), and generatePrefix().

◆ m_fullBackupPrefix

std::string FIX::FileLog::m_fullBackupPrefix
private

Definition at line 119 of file FileLog.h.

Referenced by generatePrefix().

◆ m_fullPrefix

std::string FIX::FileLog::m_fullPrefix
private

Definition at line 118 of file FileLog.h.

Referenced by generatePrefix().

◆ m_messages

std::ofstream FIX::FileLog::m_messages
private

Definition at line 114 of file FileLog.h.

Referenced by backup(), FIX::FileLogFactory::FileLogFactory(), and generatePrefix().

◆ m_messagesFileName

std::string FIX::FileLog::m_messagesFileName
private

Definition at line 116 of file FileLog.h.

Referenced by backup(), and generatePrefix().


The documentation for this class was generated from the following files:
FIX::FileLog::m_messagesFileName
std::string m_messagesFileName
Definition: FileLog.h:116
FIX::file_appendpath
std::string file_appendpath(const std::string &path, const std::string &file)
Definition: Utility.cpp:568
FIX::FileLog::m_fullPrefix
std::string m_fullPrefix
Definition: FileLog.h:118
FIX::file_fclose
void file_fclose(FILE *file)
Definition: Utility.cpp:537
FIX::file_rename
int file_rename(const char *oldpath, const char *newpath)
Definition: Utility.cpp:563
FIX::FileLog::m_messages
std::ofstream m_messages
Definition: FileLog.h:114
FIX::FileLog::m_event
std::ofstream m_event
Definition: FileLog.h:115
FIX::file_mkdir
void file_mkdir(const char *path)
Definition: Utility.cpp:506
FIX::FileLog::m_eventFileName
std::string m_eventFileName
Definition: FileLog.h:117
FIX::FileLog::m_fullBackupPrefix
std::string m_fullBackupPrefix
Definition: FileLog.h:119

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2001