logog
logger optimized for games
target.hpp
Go to the documentation of this file.
1 
5 #ifndef __LOGOG_TARGET_HPP_
6 #define __LOGOG_TARGET_HPP_
7 
8 namespace logog
9 {
16 class Target : public TopicSink
17 {
18  friend class LogBuffer;
19 public :
20  Target();
21  virtual ~Target();
22 
24  void SetFormatter( Formatter &formatter );
25 
27  Formatter &GetFormatter() const;
28 
34  virtual int Output( const LOGOG_STRING &data ) = 0;
35 
41  virtual int Receive( const Topic &topic );
42 
45 
48 
49 
50 protected:
59 };
60 
62 class Cerr : public Target
63 {
64  virtual int Output( const LOGOG_STRING &data );
65 };
66 
68 class Cout : public Target
69 {
70  virtual int Output( const LOGOG_STRING &data );
71 };
72 
76 class OutputDebug : public Target
77 {
78  virtual int Output( const LOGOG_STRING &data );
79 };
80 
86 class LogFile : public Target
87 {
88 public:
96  LogFile(const char *sFileName,
97  bool bEnableOutputBuffering = true);
98 
100  virtual ~LogFile();
101 
103  virtual int Open();
104 
110  virtual void WriteUnicodeBOM();
111 
113  virtual int Output( const LOGOG_STRING &data );
114 
119 
120 protected:
121  char *m_pFileName;
124  FILE *m_pFile;
126 
128  virtual int InternalOutput( size_t nSize, const LOGOG_CHAR *pData );
129 
130 private:
131  LogFile();
132 };
133 
139 class LogBuffer : public Target
140 {
141 public:
142  LogBuffer( Target *pTarget = NULL,
143  size_t s = LOGOG_DEFAULT_LOG_BUFFER_SIZE );
144  virtual ~LogBuffer();
145 
149  virtual void SetTarget( Target &t );
150 
154  virtual int Insert( const LOGOG_CHAR *pChars, size_t size );
155 
157  virtual int Dump();
158 
159  virtual int Output( const LOGOG_STRING &data );
160 
161 protected:
162  virtual void Allocate( size_t size );
163 
164  virtual void Deallocate();
165 
173  size_t m_nSize;
176 };
177 
178 }
179 
180 #endif // __LOGOG_TARGET_HPP_
bool m_bOpenFailed
Definition: target.hpp:123
[Thread]
Definition: api.hpp:8
Definition: target.hpp:16
#define LOGOG_STRING
Definition: string.hpp:113
bool m_bEnableOutputBuffering
Definition: target.hpp:125
LOGOG_CHAR * m_pCurrent
Definition: target.hpp:169
bool m_bNullTerminatesStrings
Definition: target.hpp:58
virtual void Deallocate()
Definition: target.hpp:62
[Mutex]
Definition: mutex.hpp:48
bool m_bFirstTime
Definition: target.hpp:122
virtual ~LogBuffer()
Definition: target.hpp:76
Definition: target.hpp:139
bool GetNullTerminatesStrings() const
Definition: target.hpp:44
virtual void Allocate(size_t size)
virtual int Insert(const LOGOG_CHAR *pChars, size_t size)
virtual void WriteUnicodeBOM()
virtual ~LogFile()
virtual int Output(const LOGOG_STRING &data)
wchar_t LOGOG_CHAR
Definition: string.hpp:14
virtual int Output(const LOGOG_STRING &data)
Definition: formatter.hpp:25
virtual int Receive(const Topic &topic)
Formatter * m_pFormatter
Definition: target.hpp:52
Formatter & GetFormatter() const
LOGOG_CHAR * m_pEnd
Definition: target.hpp:171
virtual int Output(const LOGOG_STRING &data)=0
virtual int Dump()
Definition: target.hpp:68
Target * m_pOutputTarget
Definition: target.hpp:175
bool m_bWriteUnicodeBOM
Definition: target.hpp:118
virtual int Open()
char * m_pFileName
Definition: target.hpp:121
size_t m_nSize
Definition: target.hpp:173
LogBuffer(Target *pTarget=NULL, size_t s=LOGOG_DEFAULT_LOG_BUFFER_SIZE)
void SetNullTerminatesStrings(bool val)
Definition: target.hpp:47
Mutex m_MutexReceive
Definition: target.hpp:54
FILE * m_pFile
Definition: target.hpp:124
Definition: target.hpp:86
virtual int InternalOutput(size_t nSize, const LOGOG_CHAR *pData)
void SetFormatter(Formatter &formatter)
Definition: topic.hpp:200
LOGOG_CHAR * m_pStart
Definition: target.hpp:167
Definition: topic.hpp:15
virtual void SetTarget(Target &t)
virtual ~Target()
#define LOGOG_DEFAULT_LOG_BUFFER_SIZE
Definition: const.hpp:15