FileLog.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 
3 /****************************************************************************
4 ** Copyright (c) 2001-2014
5 **
6 ** This file is part of the QuickFIX FIX Engine
7 **
8 ** This file may be distributed under the terms of the quickfixengine.org
9 ** license as defined by quickfixengine.org and appearing in the file
10 ** LICENSE included in the packaging of this file.
11 **
12 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14 **
15 ** See http://www.quickfixengine.org/LICENSE for licensing information.
16 **
17 ** Contact ask@quickfixengine.org if any conditions of this licensing are
18 ** not clear to you.
19 **
20 ****************************************************************************/
21 
22 #ifndef FIX_FILELOG_H
23 #define FIX_FILELOG_H
24 
25 #ifdef _MSC_VER
26 #pragma warning( disable : 4503 4355 4786 4290 )
27 #endif
28 
29 #include "Log.h"
30 #include "SessionSettings.h"
31 #include <fstream>
32 
33 namespace FIX
34 {
40 class FileLogFactory : public LogFactory
41 {
42 public:
43  FileLogFactory( const SessionSettings& settings )
44 : m_settings( settings ), m_globalLog(0), m_globalLogCount(0) {};
45  FileLogFactory( const std::string& path )
46 : m_path( path ), m_backupPath( path ), m_globalLog(0), m_globalLogCount(0) {};
47  FileLogFactory( const std::string& path, const std::string& backupPath )
48 : m_path( path ), m_backupPath( backupPath ), m_globalLog(0), m_globalLogCount(0) {};
49 
50 public:
51  Log* create();
52  Log* create( const SessionID& );
53  void destroy( Log* log );
54 
55 private:
56  std::string m_path;
57  std::string m_backupPath;
60  int m_globalLogCount;
61 };
62 
70 class FileLog : public Log
71 {
72 public:
73  FileLog( const std::string& path );
74  FileLog( const std::string& path, const std::string& backupPath );
75  FileLog( const std::string& path, const SessionID& sessionID );
76  FileLog( const std::string& path, const std::string& backupPath, const SessionID& sessionID );
77  virtual ~FileLog();
78 
79  void clear();
80  void backup();
81 
82  void onIncoming( const std::string& value )
83  { m_messages << UtcTimeStampConvertor::convert(UtcTimeStamp(), 9) << " : " << value << std::endl; }
84  void onOutgoing( const std::string& value )
85  { m_messages << UtcTimeStampConvertor::convert(UtcTimeStamp(), 9) << " : " << value << std::endl; }
86  void onEvent( const std::string& value )
87  {
88  UtcTimeStamp now;
90  << " : " << value << std::endl;
91  }
92 
93 private:
94  std::string generatePrefix( const SessionID& sessionID );
95  void init( std::string path, std::string backupPath, const std::string& prefix );
96 
97  std::ofstream m_messages;
98  std::ofstream m_event;
99  std::string m_messagesFileName;
100  std::string m_eventFileName;
101  std::string m_fullPrefix;
102  std::string m_fullBackupPrefix;
103 };
104 }
105 
106 #endif //FIX_LOG_H
FIX::FileLog::m_messagesFileName
std::string m_messagesFileName
Definition: FileLog.h:116
FIX::FileLog::m_fullPrefix
std::string m_fullPrefix
Definition: FileLog.h:118
SessionSettings.h
FIX::UtcTimeStamp
Date and Time represented in UTC.
Definition: FieldTypes.h:599
FIX::FileLogFactory::m_globalLog
Log * m_globalLog
Definition: FileLog.h:93
FIX::FileLog
File based implementation of Log.
Definition: FileLog.h:87
FIX::SessionID
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition: SessionID.h:47
FIX::FileLog::onEvent
void onEvent(const std::string &value)
Definition: FileLog.h:103
FIX::FileLogFactory::m_globalLogCount
int m_globalLogCount
Definition: FileLog.h:94
FIX::FileLog::m_messages
std::ofstream m_messages
Definition: FileLog.h:114
FIX::FileLogFactory::destroy
void destroy(Log *log)
Definition: FileLog.cpp:91
FIX::TYPE::UtcTimeStamp
@ UtcTimeStamp
Definition: FieldTypes.h:940
FIX::SessionSettings
Container for setting dictionaries mapped to sessions.
Definition: SessionSettings.h:237
FIX::FileLog::onOutgoing
void onOutgoing(const std::string &value)
Definition: FileLog.h:101
FIX::FileLog::backup
void backup()
Definition: FileLog.cpp:183
FIX::FileLog::~FileLog
virtual ~FileLog()
Definition: FileLog.cpp:168
FIX::UtcTimeStampConvertor::convert
static std::string convert(const UtcTimeStamp &value, int precision=0)
Definition: FieldConvertors.h:451
FIX::FileLog::m_event
std::ofstream m_event
Definition: FileLog.h:115
FIX::FileLogFactory::m_backupPath
std::string m_backupPath
Definition: FileLog.h:91
FIX
Definition: Acceptor.cpp:34
FIX::FileLog::m_eventFileName
std::string m_eventFileName
Definition: FileLog.h:117
FIX::FileLog::clear
void clear()
Definition: FileLog.cpp:174
FIX::FileLog::generatePrefix
std::string generatePrefix(const SessionID &sessionID)
Definition: FileLog.cpp:128
FIX::FileLogFactory::m_settings
SessionSettings m_settings
Definition: FileLog.h:92
FIX::FileLog::init
void init(std::string path, std::string backupPath, const std::string &prefix)
Definition: FileLog.cpp:146
FIX::FileLogFactory::FileLogFactory
FileLogFactory(const SessionSettings &settings)
Definition: FileLog.h:77
FIX::FileLogFactory::create
Log * create()
Definition: FileLog.cpp:47
FIX::FileLog::FileLog
FileLog(const std::string &path)
Definition: FileLog.cpp:108
FIX::FileLog::onIncoming
void onIncoming(const std::string &value)
Definition: FileLog.h:99
FIX::Log
This interface must be implemented to log messages and events.
Definition: Log.h:98
Log.h
FIX::FileLogFactory::m_path
std::string m_path
Definition: FileLog.h:90
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