#include <CLogger.h>
Public Member Functions | |
CLogger (char *_pcLogFileName) | |
FILE * | FileHandle (void) const |
void | LogEnd (void) |
void | LogError (const char *_pcFormat,...) |
char * | LogFileName (void) const |
void | LogFunction (const char *_pcFormat,...) |
void | LoggingEnabled (bool _bLog) |
bool | LoggingEnabled (void) const |
void | LogMessage (const char *_pcFormat,...) |
void | LogStart (void) |
~CLogger () | |
Private Member Functions | |
void | LogEntry (const char *_pcFormat,...) |
Private Attributes | |
char | m_acTemp [512] |
bool | m_bLoggingEnabled |
FILE * | m_hLogFile |
char * | m_pcLogFileName |
This can be used from anywhere to either write XML to a global log file (see: g_pGlobalLog), or use a local instantiation for (for example) specific object/class logs (or whatever, really!). This is obviously not a singleton.
Definition at line 58 of file CLogger.h.
|
Consturctor. Opens/creates the logfile, writes the header.
Definition at line 83 of file CLogger.cpp. References LoggingEnabled(), LogMessage(), LogStart(), m_hLogFile, and m_pcLogFileName. 00084 { 00085 m_pcLogFileName = new char [ strlen(pcLogFileName) + 1 ]; 00086 strcpy(m_pcLogFileName, pcLogFileName); 00087 m_hLogFile = fopen(m_pcLogFileName, "w"); 00088 LogStart(); 00089 LogMessage("Log Started."); 00090 LoggingEnabled(true); 00091 }
|
Here is the call graph for this function:
|
Destructor. Close the file and cleanup. Definition at line 122 of file CLogger.cpp. References m_hLogFile. 00123 {
00124 fclose(m_hLogFile);
00125 delete m_pcLogFileName;
00126 }
|
|
Definition at line 68 of file CLogger.h. 00068 {return m_hLogFile;}
|
|
Writes the footer for the log XML. Definition at line 111 of file CLogger.cpp. References LogEntry(). 00112 { 00113 LogEntry("</log>\n"); 00114 }
|
Here is the call graph for this function:
|
Writes a log entry to the file, copies format of printf. Called by LogMessage(), LogError() and LogFunction().
Definition at line 152 of file CLogger.cpp. References m_acTemp, and m_hLogFile. Referenced by LogEnd(), LogError(), LogFunction(), LoggingEnabled(), LogMessage(), and LogStart(). 00153 { 00154 if(m_hLogFile==0) 00155 return; 00156 00157 int iLen; 00158 00159 va_list argList; 00160 00161 va_start(argList, pcFormat); 00162 iLen = vsprintf(m_acTemp, pcFormat, argList); 00163 va_end(argList); 00164 00165 fprintf(m_hLogFile, m_acTemp); 00166 }
|
|
Writes a error log entry to the file, copies format of printf.
Definition at line 227 of file CLogger.cpp. References LogEntry(). 00228 { 00229 if(!m_bLoggingEnabled) 00230 return; 00231 00232 int iLen; 00233 00234 va_list argList; 00235 char acTemp[256]; 00236 00237 va_start(argList, pcFormat); 00238 iLen = vsprintf(acTemp, pcFormat, argList); 00239 va_end(argList); 00240 00241 LogEntry("<error text=\"%s\" />\n", acTemp); 00242 }
|
Here is the call graph for this function:
|
Definition at line 67 of file CLogger.h. 00067 {return m_pcLogFileName;}
|
|
Writes a function log entry to the file, copies format of printf.
Definition at line 202 of file CLogger.cpp. References LogEntry(). 00203 { 00204 if(!m_bLoggingEnabled) 00205 return; 00206 00207 int iLen; 00208 00209 va_list argList; 00210 char acTemp[256]; 00211 00212 va_start(argList, pcFormat); 00213 iLen = vsprintf(acTemp, pcFormat, argList); 00214 va_end(argList); 00215 00216 LogEntry("<function name=\"%s\" />\n", acTemp); 00217 }
|
Here is the call graph for this function:
|
Enable or disable logging for this instance. Definition at line 134 of file CLogger.cpp. References LogEntry(), and m_bLoggingEnabled. 00135 { 00136 m_bLoggingEnabled = _bLog; 00137 if(_bLog) 00138 LogEntry("<message text=\"Logging Enabled.\" />\n"); 00139 else 00140 LogEntry("<message text=\"Logging Disabled.\" />\n"); 00141 }
|
Here is the call graph for this function:
|
Definition at line 69 of file CLogger.h. Referenced by CLogger(). 00069 {return m_bLoggingEnabled;}
|
|
Writes a message log entry to the file, copies format of printf.
Definition at line 176 of file CLogger.cpp. References LogEntry(). Referenced by CLogger(). 00177 { 00178 if(!m_bLoggingEnabled) 00179 return; 00180 00181 int iLen; 00182 00183 va_list argList; 00184 char acTemp[256]; 00185 00186 va_start(argList, pcFormat); 00187 iLen = vsprintf(acTemp, pcFormat, argList); 00188 va_end(argList); 00189 00190 LogEntry("<message text=\"%s\" />\n", acTemp); 00191 }
|
Here is the call graph for this function:
|
Writes the header to the logfile. Definition at line 99 of file CLogger.cpp. References LogEntry(). Referenced by CLogger(). 00100 { 00101 LogEntry("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"); 00102 LogEntry("<log>\n"); 00103 }
|
Here is the call graph for this function:
|
Definition at line 83 of file CLogger.h. Referenced by LogEntry(). |
|
Definition at line 84 of file CLogger.h. Referenced by LoggingEnabled(). |
|
Definition at line 81 of file CLogger.h. Referenced by CLogger(), LogEntry(), and ~CLogger(). |
|
Definition at line 82 of file CLogger.h. Referenced by CLogger(). |