00001
00002
00004
00005
#if !defined(AFX_LOGGER_H__D5C75D23_D1A5_43BE_A6F3_3778FDD8A669__INCLUDED_)
00006
#define AFX_LOGGER_H__D5C75D23_D1A5_43BE_A6F3_3778FDD8A669__INCLUDED_
00007
00008
#if _MSC_VER > 1000
00009
#pragma once
00010
#endif // _MSC_VER > 1000
00011
00012
00013
#define USE_GLOBAL_LOGGER 1
00014
00015
#include "Singleton.h"
00016
#include <stdarg.h>
00017
#include <stdio.h>
00018
00020
00025 class CLogger
00026 {
00027
public:
00028
00029
CLogger();
00030
CLogger(
char *pcFilename,
bool bKeepOpen =
false,
bool bAppend =
false);
00031
virtual ~
CLogger();
00032
00039
virtual int Open(
char *pcFilename,
bool bKeepOpen =
false,
bool bAppend =
false);
00040
00041
00046
virtual int Write(
const char *pcFormat, ...);
00047
00052
virtual int Append(
const char *pcFormat, ...);
00053
00057
virtual int Erase();
00061
virtual int Close();
00062
00064
int GetError();
00065
00066
private:
00067
00068 FILE *m_pFile;
00069
char m_strFilename[256];
00070
bool m_bKeepOpen;
00071 };
00072
#endif // !defined(AFX_LOGGER_H__D5C75D23_D1A5_43BE_A6F3_3778FDD8A669__INCLUDED_)
00073
00074
#ifdef USE_GLOBAL_LOGGER
00075
00076
00081 class CGlobalLogger :
public CLogger,
public CSingleton<CGlobalLogger>
00082 {
00083
public:
00084
00085
CGlobalLogger();
00086
CGlobalLogger(
char *pcFilename);
00087
virtual ~
CGlobalLogger();
00088
00089
void SetLogLevel(
int iLogLevel);
00090
int GetLogLevel();
00094
virtual int Open(
char *pcFilename,
bool bKeepOpen =
true);
00098
virtual int Close();
00099
00100
private:
00101
int m_iLogLevel;
00102
00103 };
00104
00105
#endif