sptk2 logo
SPTK Home Page

sptk::CBaseLog Class Reference
[Log Classes]

Base class for all log classes. More...

#include <CBaseLog.h>

Inheritance diagram for sptk::CBaseLog:

sptk::CSynchronized sptk::CFileLog sptk::CProxyLog sptk::CSysLog

List of all members.

Public Types

enum  CLogOption {
  CLO_STDOUT = 1, CLO_DATE = 2, CLO_TIME = 4, CLO_PRIORITY = 8,
  CLO_ENABLE = 16
}
 Log options. More...

Public Member Functions

virtual void saveMessage (CDateTime date, const char *message, uint32_t sz, const CLogPriority *priority) throw (CException)
 Stores or sends log message to actual destination.
virtual ~CBaseLog ()
 Destructor Flushes the log and releases any allocated resources.
void options (int ops)
 Sets log options.
int options () const
 Returns log options.
void option (CLogOption option, bool flag)
 Sets an option to true or false.
void priority (const CLogPriority &prt)
 Sets current message priority.
virtual void reset () throw (CException)
 Restarts the log, if applicable In CBaseLog it does nothing.
virtual void defaultPriority (CLogPriority &priority)
 Sets the default priority.
virtual const CLogPrioritydefaultPriority () const
 Returns the default priority.
virtual void minPriority (const CLogPriority &prt)
 Sets min message priority.
virtual const CLogPriorityminPriority () const
 Returns the min priority.

Protected Member Functions

 CBaseLog ()
 Protected constructor.

Protected Attributes

CLogStreamBuf m_buffer
 Log buffer.
int m_indent
 Text indent.
const CLogPrioritym_defaultPriority
 The default priority for the new message.
const CLogPrioritym_minPriority
 Min message priority, should be defined for every message.
int m_options
 Log options, a bit combination of CLogOption.

Friends

class CFunctionLogger
class CLogStreamBuf


Detailed Description

Base class for all log classes.

Member Enumeration Documentation

Log options.

Enumerator:
CLO_STDOUT  Duplicate messages to stdout.
CLO_DATE  Print date for every log message.
CLO_TIME  Print time for every log message.
CLO_PRIORITY  Print message priority.
CLO_ENABLE  Enable logging (doesn't affect stdout if CLO_STDOUT is on).


Constructor & Destructor Documentation

sptk::CBaseLog::CBaseLog (  )  [inline, protected]

Protected constructor.

Creates an empty log object. You should never try to instantiate this class. CBaseLog can only be used as a base class for log classes that implement at least saveMessage() method. The default message priority is CLP_NOTICE.

References CLO_DATE, CLO_ENABLE, CLO_PRIORITY, CLO_TIME, sptk::CLP_NOTICE, m_buffer, m_defaultPriority, m_indent, m_minPriority, m_options, and sptk::CLogStreamBuf::parent().


Member Function Documentation

virtual const CLogPriority& sptk::CBaseLog::defaultPriority (  )  const [inline, virtual]

Returns the default priority.

The default priority is used for the new message, if you are not defining priority.

Reimplemented in sptk::CProxyLog.

References m_defaultPriority.

virtual void sptk::CBaseLog::defaultPriority ( CLogPriority priority  )  [inline, virtual]

Sets the default priority.

The default priority is used for the new message, if you are not defining priority.

Parameters:
priority CLogPriority&, new default priority

Reimplemented in sptk::CProxyLog.

References m_defaultPriority.

Referenced by sptk::CProxyLog::defaultPriority().

virtual const CLogPriority& sptk::CBaseLog::minPriority (  )  const [inline, virtual]

Returns the min priority.

Messages with priority less than requested are ignored

Reimplemented in sptk::CProxyLog.

References m_minPriority.

virtual void sptk::CBaseLog::minPriority ( const CLogPriority prt  )  [inline, virtual]

Sets min message priority.

Messages with priority less than requested are ignored

Parameters:
prt const CLogPriority&, min message priority

Reimplemented in sptk::CProxyLog.

References m_minPriority.

Referenced by sptk::CProxyLog::minPriority().

int sptk::CBaseLog::options (  )  const [inline]

Returns log options.

Returns:
a bit combination of CLogOption

References m_options.

void sptk::CBaseLog::options ( int  ops  )  [inline]

Sets log options.

Parameters:
ops int, a bit combination of CLogOption

References m_options.

void sptk::CBaseLog::priority ( const CLogPriority prt  )  [inline]

Sets current message priority.

Parameters:
prt const CLogPriority&, current message priority

References m_buffer, and sptk::CLogStreamBuf::priority().

virtual void sptk::CBaseLog::saveMessage ( CDateTime  date,
const char *  message,
uint32_t  sz,
const CLogPriority priority 
) throw (CException) [inline, virtual]

Stores or sends log message to actual destination.

This method should be overwritten by the actual log implementation

Parameters:
date CDateTime, message timestamp
message const char *, message text
sz uint32_t, message size
priority CLogPriority, message priority.
See also:
CLogPriority for more information.

Reimplemented in sptk::CFileLog, sptk::CProxyLog, and sptk::CSysLog.


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

Mon Mar 5 11:55:56 2012: SPTK 3.5.7