FileLog.h
Go to the documentation of this file.
/* -*- C++ -*- */
/****************************************************************************
** Copyright (c) 2001-2014
**
** This file is part of the QuickFIX FIX Engine
**
** This file may be distributed under the terms of the quickfixengine.org
** license as defined by quickfixengine.org and appearing in the file
** LICENSE included in the packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.quickfixengine.org/LICENSE for licensing information.
**
** Contact ask@quickfixengine.org if any conditions of this licensing are
** not clear to you.
**
****************************************************************************/
#ifndef FIX_FILELOG_H
#define FIX_FILELOG_H
#ifdef _MSC_VER
#pragma warning( disable : 4503 4355 4786 4290 )
#endif
#include "Log.h"
#include "SessionSettings.h"
#include <fstream>
namespace FIX
{
class FileLogFactory : public LogFactory
{
public:
FileLogFactory( const SessionSettings& settings )
: m_settings( settings ), m_globalLog(0), m_globalLogCount(0) {};
FileLogFactory( const std::string& path )
: m_path( path ), m_backupPath( path ), m_globalLog(0), m_globalLogCount(0) {};
FileLogFactory( const std::string& path, const std::string& backupPath )
: m_path( path ), m_backupPath( backupPath ), m_globalLog(0), m_globalLogCount(0) {};
public:
Log* create();
Log* create( const SessionID& );
void destroy( Log* log );
private:
std::string m_path;
std::string m_backupPath;
SessionSettings m_settings;
Log* m_globalLog;
int m_globalLogCount;
};
class FileLog : public Log
{
public:
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 )
{ m_messages << UtcTimeStampConvertor::convert(UtcTimeStamp(), m_millisecondsInTimeStamp) << " : " << value << std::endl; }
void onOutgoing( const std::string& value )
{ m_messages << UtcTimeStampConvertor::convert(UtcTimeStamp(), m_millisecondsInTimeStamp) << " : " << value << std::endl; }
void onEvent( const std::string& value )
{
UtcTimeStamp now;
m_event << UtcTimeStampConvertor::convert( now, m_millisecondsInTimeStamp )
<< " : " << value << std::endl;
}
bool getMillisecondsInTimeStamp() const
{ return m_millisecondsInTimeStamp; }
void setMillisecondsInTimeStamp ( bool value )
{ m_millisecondsInTimeStamp = value; }
private:
std::string generatePrefix( const SessionID& sessionID );
void init( std::string path, std::string backupPath, const std::string& prefix );
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;
};
}
#endif //FIX_LOG_H
FIX::FileLogFactory::m_path
std::string m_path
Definition: FileLog.h:56
SessionSettings.h
FIX::FileLogFactory
Creates a file based implementation of Log.
Definition: FileLog.h:40
FIX::FileLog
File based implementation of Log.
Definition: FileLog.h:70
FIX::FileLogFactory::FileLogFactory
FileLogFactory(const std::string &path)
Definition: FileLog.h:45
FIX::FileLog::m_fullPrefix
std::string m_fullPrefix
Definition: FileLog.h:106
FIX::UtcTimeStampConvertor::convert
static std::string convert(const UtcTimeStamp &value, bool showMilliseconds=false)
Definition: FieldConvertors.h:566
FIX::FileLogFactory::m_globalLogCount
int m_globalLogCount
Definition: FileLog.h:60
FIX::FileLog::m_messages
std::ofstream m_messages
Definition: FileLog.h:102
FIX::FileLog::onIncoming
void onIncoming(const std::string &value)
Definition: FileLog.h:82
FIX::FileLogFactory::m_backupPath
std::string m_backupPath
Definition: FileLog.h:57
FIX::FileLogFactory::destroy
void destroy(Log *log)
Definition: FileLog.cpp:74
FIX::FileLog::m_eventFileName
std::string m_eventFileName
Definition: FileLog.h:105
Log.h
FIX::Log
This interface must be implemented to log messages and events.
Definition: Log.h:81
FIX::FileLog::onEvent
void onEvent(const std::string &value)
Definition: FileLog.h:86
FIX
Definition: Acceptor.cpp:34
FIX::FileLog::m_event
std::ofstream m_event
Definition: FileLog.h:103
FIX::FileLogFactory::m_settings
SessionSettings m_settings
Definition: FileLog.h:58
FIX::FileLogFactory::FileLogFactory
FileLogFactory(const SessionSettings &settings)
Definition: FileLog.h:43
FIX::SessionSettings
Container for setting dictionaries mapped to sessions.
Definition: SessionSettings.h:130
FIX::FileLog::m_fullBackupPrefix
std::string m_fullBackupPrefix
Definition: FileLog.h:107
FIX::FileLog::onOutgoing
void onOutgoing(const std::string &value)
Definition: FileLog.h:84
FIX::FileLogFactory::FileLogFactory
FileLogFactory(const std::string &path, const std::string &backupPath)
Definition: FileLog.h:47
FIX::FileLogFactory::create
Log * create()
Definition: FileLog.cpp:30
FIX::LogFactory
This interface must be implemented to create a Log.
Definition: Log.h:42
FIX::FileLog::m_millisecondsInTimeStamp
bool m_millisecondsInTimeStamp
Definition: FileLog.h:108
FIX::TYPE::UtcTimeStamp
Definition: FieldTypes.h:674
FIX::UtcTimeStamp
Date and Time represented in UTC.
Definition: FieldTypes.h:399
FIX::FileLog::m_messagesFileName
std::string m_messagesFileName
Definition: FileLog.h:104
FIX::SessionID
Unique session id consists of BeginString, SenderCompID and TargetCompID.
Definition: SessionID.h:30
FIX::FileLog::getMillisecondsInTimeStamp
bool getMillisecondsInTimeStamp() const
Definition: FileLog.h:93
FIX::FileLog::setMillisecondsInTimeStamp
void setMillisecondsInTimeStamp(bool value)
Definition: FileLog.h:95
FIX::FileLogFactory::m_globalLog
Log * m_globalLog
Definition: FileLog.h:59