logog
logger optimized for games
LogFile Class Reference

#include <target.hpp>

+ Inheritance diagram for LogFile:

Public Member Functions

 LogFile (const char *sFileName, bool bEnableOutputBuffering=true)
 
virtual ~LogFile ()
 
virtual int Open ()
 
virtual void WriteUnicodeBOM ()
 
virtual int Output (const LOGOG_STRING &data)
 
- Public Member Functions inherited from Target
 Target ()
 
virtual ~Target ()
 
void SetFormatter (Formatter &formatter)
 
FormatterGetFormatter () const
 
virtual int Receive (const Topic &topic)
 
bool GetNullTerminatesStrings () const
 
void SetNullTerminatesStrings (bool val)
 
- Public Member Functions inherited from TopicSink
virtual bool IsTopic () const
 
virtual void Initialize ()
 
virtual bool PublishTo (Node &)
 
virtual bool UnpublishTo (Node &)
 
virtual bool CanPublish () const
 
- Public Member Functions inherited from Topic
 Topic (const LOGOG_LEVEL_TYPE level=LOGOG_LEVEL_ALL, const LOGOG_CHAR *sFileName=NULL, const int nLineNumber=0, const LOGOG_CHAR *sGroup=NULL, const LOGOG_CHAR *sCategory=NULL, const LOGOG_CHAR *sMessage=NULL, const double dTimestamp=0.0f)
 
virtual int Send (const Topic &node)
 
virtual int Transmit ()
 
virtual bool CanSubscribeTo (const Node &otherNode)
 
virtual bool CanSubscribeCheckTopic (const Topic &other)
 
virtual void Format (const LOGOG_CHAR *cFormatMessage,...)
 
const LOGOG_STRINGFileName () const
 
void FileName (const LOGOG_STRING &s)
 
const LOGOG_STRINGMessage () const
 
void Message (const LOGOG_STRING &s)
 
const LOGOG_STRINGCategory () const
 
void Category (const LOGOG_STRING &s)
 
const LOGOG_STRINGGroup () const
 
void Group (const LOGOG_STRING &s)
 
int LineNumber () const
 
void LineNumber (const int num)
 
LOGOG_LEVEL_TYPE Level () const
 
void Level (LOGOG_LEVEL_TYPE level)
 
LOGOG_TIME Timestamp () const
 
void Timestamp (const LOGOG_TIME t)
 
TOPIC_FLAGS GetTopicFlags () const
 
- Public Member Functions inherited from Node
 Node ()
 
 ~Node ()
 
virtual bool CanSubscribe () const
 
virtual bool PublishToMultiple (LockableNodesType &nodes)
 
virtual bool UnpublishToMultiple (LockableNodesType &nodes)
 
virtual bool SubscribeTo (Node &publisher)
 
virtual bool SubscribeToMultiple (LockableNodesType &nodes)
 
virtual bool UnsubscribeTo (Node &publisher)
 
virtual bool UnsubscribeToMultiple (LockableNodesType &nodes)
 
void Clear ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
void * operator new (size_t nSize)
 
void * operator new[] (size_t nSize)
 
void operator delete (void *ptr)
 
void operator delete[] (void *ptr)
 

Public Attributes

bool m_bWriteUnicodeBOM
 
- Public Attributes inherited from Node
void * m_pUserData1
 
void * m_pUserData2
 

Protected Member Functions

virtual int InternalOutput (size_t nSize, const LOGOG_CHAR *pData)
 

Protected Attributes

char * m_pFileName
 
bool m_bFirstTime
 
bool m_bOpenFailed
 
FILE * m_pFile
 
bool m_bEnableOutputBuffering
 
- Protected Attributes inherited from Target
Formatterm_pFormatter
 
Mutex m_MutexReceive
 
bool m_bNullTerminatesStrings
 
- Protected Attributes inherited from Topic
LOGOG_STRING m_vStringProps [TOPIC_STRING_COUNT]
 
int m_vIntProps [TOPIC_INT_COUNT]
 
LOGOG_TIME m_tTime
 
TOPIC_FLAGS m_TopicFlags
 
- Protected Attributes inherited from Node
LockableNodesType m_Subscribers
 
LockableNodesType m_Publishers
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static void * Allocate (size_t nSize)
 
static void Deallocate (void *ptr)
 

Detailed Description

A LogFile renders received messages to a file. Provide the name of the file to be rendered to as a parameter to the construction of the LogFile() object. Destroying a LogFile object will cause the output file to be closed. LogFile objects always append to the output file; they do not delete the previous log file.

Constructor & Destructor Documentation

LogFile ( const char *  sFileName,
bool  bEnableOutputBuffering = true 
)

Creates a LogFile object.

Parameters
sFileNameThe name of the file to be created. Since file names do not support Unicode on most systems, there is no option to create a filename with a LOGOG_CHAR.
bEnableOutputBufferingWhether to perform output buffering, or flush after each write.
virtual ~LogFile ( )
virtual

Closes the log file.

Member Function Documentation

virtual int InternalOutput ( size_t  nSize,
const LOGOG_CHAR pData 
)
protectedvirtual

Does the actual fwrite to the file. Call Output() instead to handle error conditions better.

virtual int Open ( )
virtual

Opens the log file on first write.

virtual int Output ( const LOGOG_STRING data)
virtual

Writes the message to the log file.

Implements Target.

virtual void WriteUnicodeBOM ( )
virtual

This function makes a guess as to the correct BOM for this file, and attempts to write it into the file. It does this by considering the size of LOGOG_CHAR as well as considering the current endianness of this system. This guess may be incorrect.

Member Data Documentation

bool m_bEnableOutputBuffering
protected
bool m_bFirstTime
protected
bool m_bOpenFailed
protected
bool m_bWriteUnicodeBOM

Should a Unicode BOM be written to the beginning of this log file, if the log file was previously empty? By default a BOM is written to a log file if LOGOG_UNICODE is enabled.

FILE* m_pFile
protected
char* m_pFileName
protected

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