SWLog Class Reference

#include <swlog.h>

Collaboration diagram for SWLog:
Collaboration graph
[legend]

List of all members.

Public Member Functions

char getLogLevel () const
void logDebug (const char *fmt,...) const
void logError (const char *fmt,...) const
void logInformation (const char *fmt,...) const
virtual void logMessage (const char *message, int level) const
virtual void logTimedInformation (const char *fmt,...) const
void logWarning (const char *fmt,...) const
void setLogLevel (char level)
 SWLog ()
virtual ~SWLog ()

Static Public Member Functions

static SWLoggetSystemLog ()
static void setSystemLog (SWLog *newLogger)

Static Public Attributes

static const int LOG_DEBUG = 5
static const int LOG_ERROR = 1
static const int LOG_INFO = 3
static const int LOG_TIMEDINFO = 4
static const int LOG_WARN = 2

Protected Attributes

char logLevel

Static Protected Attributes

static SWLogsystemLog = 0

Detailed Description

Definition at line 31 of file swlog.h.


Constructor & Destructor Documentation

SWLog::SWLog (  )  [inline]

Definition at line 47 of file swlog.h.

00047 { logLevel = 1; /*default to show only errors*/}

virtual SWLog::~SWLog (  )  [inline, virtual]

Definition at line 48 of file swlog.h.

00048 {};


Member Function Documentation

char SWLog::getLogLevel (  )  const [inline]

Definition at line 51 of file swlog.h.

00051 { return logLevel; }

SWLog * SWLog::getSystemLog (  )  [static]

Definition at line 42 of file swlog.cpp.

00042                            {
00043     static class __staticSystemLog {
00044     SWLog **clear;
00045     public:
00046         __staticSystemLog(SWLog **clear) { this->clear = clear; }
00047         ~__staticSystemLog() { delete *clear; *clear = 0; }
00048     } _staticSystemLog(&SWLog::systemLog);
00049 
00050     if (!systemLog)
00051         systemLog = new SWLog();
00052 
00053     return systemLog;
00054 }

void SWLog::logDebug ( const char *  fmt,
  ... 
) const

Definition at line 115 of file swlog.cpp.

00115                                                {
00116     char msg[2048];
00117     va_list argptr;
00118 
00119     if (logLevel >= LOG_DEBUG) {
00120         va_start(argptr, fmt);
00121         vsprintf(msg, fmt, argptr);
00122         va_end(argptr);
00123         logMessage(msg, LOG_DEBUG);
00124     }
00125 }

void SWLog::logError ( const char *  fmt,
  ... 
) const

Definition at line 76 of file swlog.cpp.

00076                                                {
00077     char msg[2048];
00078     va_list argptr;
00079 
00080     if (logLevel) {
00081         va_start(argptr, fmt);
00082         vsprintf(msg, fmt, argptr);
00083         va_end(argptr);
00084         logMessage(msg, LOG_ERROR);
00085     }
00086 }

void SWLog::logInformation ( const char *  fmt,
  ... 
) const

Definition at line 89 of file swlog.cpp.

00089                                                      {
00090     char msg[2048];
00091     va_list argptr;
00092 
00093     if (logLevel >= LOG_INFO) {
00094         va_start(argptr, fmt);
00095         vsprintf(msg, fmt, argptr);
00096         va_end(argptr);
00097         logMessage(msg, LOG_INFO);
00098     }
00099 }

void SWLog::logMessage ( const char *  message,
int  level 
) const [virtual]

Definition at line 127 of file swlog.cpp.

00127                                                            {
00128     std::cerr << message;
00129     std::cerr << std::endl;
00130 }

void SWLog::logTimedInformation ( const char *  fmt,
  ... 
) const [virtual]

Definition at line 102 of file swlog.cpp.

00102                                                           {
00103     char msg[2048];
00104     va_list argptr;
00105 
00106     if (logLevel >= LOG_TIMEDINFO) {
00107         va_start(argptr, fmt);
00108         vsprintf(msg, fmt, argptr);
00109         va_end(argptr);
00110         logMessage(msg, LOG_TIMEDINFO);
00111     }
00112 }

void SWLog::logWarning ( const char *  fmt,
  ... 
) const

Definition at line 63 of file swlog.cpp.

00063                                                  {
00064     char msg[2048];
00065     va_list argptr;
00066 
00067     if (logLevel >= LOG_WARN) {
00068         va_start(argptr, fmt);
00069         vsprintf(msg, fmt, argptr);
00070         va_end(argptr);
00071         logMessage(msg, LOG_WARN);
00072     }
00073 }

void SWLog::setLogLevel ( char  level  )  [inline]

Definition at line 50 of file swlog.h.

00050 { logLevel = level; }

void SWLog::setSystemLog ( SWLog newLogger  )  [static]

Definition at line 57 of file swlog.cpp.

00057                                       {
00058     delete getSystemLog();
00059     systemLog = newLog;
00060 }


Member Data Documentation

const int SWLog::LOG_DEBUG = 5 [static]

Definition at line 42 of file swlog.h.

const int SWLog::LOG_ERROR = 1 [static]

Definition at line 38 of file swlog.h.

const int SWLog::LOG_INFO = 3 [static]

Definition at line 40 of file swlog.h.

const int SWLog::LOG_TIMEDINFO = 4 [static]

Definition at line 41 of file swlog.h.

const int SWLog::LOG_WARN = 2 [static]

Definition at line 39 of file swlog.h.

char SWLog::logLevel [protected]

Definition at line 33 of file swlog.h.

SWORD_NAMESPACE_START SWLog * SWLog::systemLog = 0 [static, protected]

Definition at line 34 of file swlog.h.


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

Generated on 18 Mar 2013 for The SWORD Project by  doxygen 1.6.1