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 85 of file FileLog.h.

Constructor & Destructor Documentation

◆ FileLog() [1/4]

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

Definition at line 107 of file FileLog.cpp.

107 {
108  init( path, backupPath, generatePrefix(s) );
109 }
110 

References generatePrefix(), and init().

◆ FileLog() [2/4]

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

Definition at line 112 of file FileLog.cpp.

112 {
113  const std::string& begin =
114  s.getBeginString().getString();
115  const std::string& sender =

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

◆ FileLog() [3/4]

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

Definition at line 117 of file FileLog.cpp.

◆ FileLog() [4/4]

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

Definition at line 122 of file FileLog.cpp.

◆ ~FileLog()

FIX::FileLog::~FileLog ( )
virtual

Definition at line 167 of file FileLog.cpp.

167 {
168  m_messages.close();
169  m_event.close();
170 
171  int i = 0;

References m_event, and m_messages.

Member Function Documentation

◆ backup()

void FIX::FileLog::backup ( )
virtual

Implements FIX::Log.

Definition at line 182 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 173 of file FileLog.cpp.

173  {
174  std::stringstream messagesFileName;
175  std::stringstream eventFileName;
176 
177  messagesFileName << m_fullBackupPrefix << "messages.backup." << ++i << ".log";
178  eventFileName << m_fullBackupPrefix << "event.backup." << i << ".log";
179  FILE* messagesLogFile = file_fopen( messagesFileName.str().c_str(), "r" );
180  FILE* eventLogFile = file_fopen( eventFileName.str().c_str(), "r" );

References FIX::file_fopen(), and m_fullBackupPrefix.

◆ generatePrefix()

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

Definition at line 127 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";

Referenced by FileLog().

◆ init()

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

Definition at line 145 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 

Referenced by FIX::FileLogFactory::destroy(), and FileLog().

◆ onEvent()

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

Implements FIX::Log.

Definition at line 101 of file FileLog.h.

◆ onIncoming()

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

Implements FIX::Log.

Definition at line 97 of file FileLog.h.

◆ onOutgoing()

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

Implements FIX::Log.

Definition at line 99 of file FileLog.h.

Member Data Documentation

◆ m_event

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

Definition at line 113 of file FileLog.h.

Referenced by backup(), and ~FileLog().

◆ m_eventFileName

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

Definition at line 115 of file FileLog.h.

Referenced by backup().

◆ m_fullBackupPrefix

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

Definition at line 117 of file FileLog.h.

Referenced by clear().

◆ m_fullPrefix

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

Definition at line 116 of file FileLog.h.

◆ m_messages

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

Definition at line 112 of file FileLog.h.

Referenced by backup(), and ~FileLog().

◆ m_messagesFileName

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

Definition at line 114 of file FileLog.h.

Referenced by backup().


The documentation for this class was generated from the following files:
FIX::FileLog::m_messagesFileName
std::string m_messagesFileName
Definition: FileLog.h:114
FIX::file_appendpath
std::string file_appendpath(const std::string &path, const std::string &file)
Definition: Utility.cpp:566
FIX::FileLog::m_fullPrefix
std::string m_fullPrefix
Definition: FileLog.h:116
FIX::file_fclose
void file_fclose(FILE *file)
Definition: Utility.cpp:535
FIX::file_rename
int file_rename(const char *oldpath, const char *newpath)
Definition: Utility.cpp:561
FIX::FileLog::m_messages
std::ofstream m_messages
Definition: FileLog.h:112
FIX::FileLog::m_event
std::ofstream m_event
Definition: FileLog.h:113
FIX::file_mkdir
void file_mkdir(const char *path)
Definition: Utility.cpp:504
FIX::FileLog::m_eventFileName
std::string m_eventFileName
Definition: FileLog.h:115
FIX::FileLog::generatePrefix
std::string generatePrefix(const SessionID &sessionID)
Definition: FileLog.cpp:127
FIX::file_fopen
FILE * file_fopen(const char *path, const char *mode)
Definition: Utility.cpp:524
FIX::FileLog::init
void init(std::string path, std::string backupPath, const std::string &prefix)
Definition: FileLog.cpp:145
FIX::FileLog::m_fullBackupPrefix
std::string m_fullBackupPrefix
Definition: FileLog.h:117

Generated on Thu Apr 23 2020 04:32:03 for QuickFIX by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2001