fs::sys::Log_t Class Reference

#include <fsLog.h>

Inheritance diagram for fs::sys::Log_t:

Inheritance graph
[legend]
Collaboration diagram for fs::sys::Log_t:

Collaboration graph
[legend]
List of all members.

Detailed Description

Log system.

An extra effort was made to provide two key features: Individual log instances can be linked together and they can rest in different DLL modules. Before a module is connected, logged data are typically stored in log history. After connecting, the history is dumped into the main log and all future logged data are also redirected. The Fig. below shows such a module-based system.

fs_sys_Log_t_01.gif

The internal logic of Log_t recognizes special control sequences in the message. Prefix '!.' means warning, 'x.' means error. Postfix '@' is an explicit request for message break invoking through the FS_ASSERT_MSG macro.

Configuration

Implementation notes:
The PIMPL idiom and the virtual interface concept are used together to cross DLL bounds if necessary.
Examples:

_tests/fsLog/main.cpp.

Definition at line 76 of file fsLog.h.

Public Types

 LOG_HIST = 0x00000001
 Keep records in history.
 LOG_FILE = 0x00000002
 Log to a file.
 LOG_STDOUT = 0x00000004
 Log to the standard output.
 LOG_DBGOUT = 0x00000008
 Log through OutputDebugString.
 LOG_RTMBRK = 0x00000010
 Enable runtime break.
enum  Mode_e {
  LOG_HIST = 0x00000001, LOG_FILE = 0x00000002, LOG_STDOUT = 0x00000004, LOG_DBGOUT = 0x00000008,
  LOG_RTMBRK = 0x00000010
}
 Configuration flags. More...

Public Member Functions

 Log_t (unsigned int fMode, size_t uHist=1024, const char *pszFile="fs.log")
 Initializes a new log instance using the given configuration.
virtual ~Log_t ()
 Releases links and resources (e.g. closes log file).
void Push (const char *pszFmt,...)
 Logs a formated string ('printf' style).
virtual void SetTgt (Log_t *pTgt)
 Sets a new target log (dumps history, redirects future records).

Protected Member Functions

 Log_t ()
 Used only by 'LogImpl_t'.
virtual void RegSrc (Log_t *pSrc, bool bReg=true)
 Links / unlinks log instances.
virtual void PushLn (const char *pszText, bool bMsgBrk=false)
 Logs a text line.

Private Member Functions

 Log_t (const Log_t &)
 No copy.
Log_toperator= (const Log_t &)
 No assignment.

Private Attributes

Log_tm_pImpl
 The PIPML idiom is used.

Friends

class LogImpl_t


Member Enumeration Documentation

enum fs::sys::Log_t::Mode_e

Configuration flags.

Enumerator:
LOG_HIST  Keep records in history.
LOG_FILE  Log to a file.
LOG_STDOUT  Log to the standard output.
LOG_DBGOUT  Log through OutputDebugString.
LOG_RTMBRK  Enable runtime break.

Definition at line 81 of file fsLog.h.


Constructor & Destructor Documentation

Log_t::Log_t ( unsigned int  fMode,
size_t  uHist = 1024,
const char *  pszFile = "fs.log" 
) [explicit]

Initializes a new log instance using the given configuration.

Parameters:
fMode Configuration flags (see Mode_e).
uHist History depth (in combination with LOG_HIST).
pszFile Filename of the log file (in combination with LOG_FILE).

Definition at line 250 of file fsLog.cpp.

References FS_ASSERT_MSG, and m_pImpl.

Log_t::~Log_t (  )  [virtual]

Releases links and resources (e.g. closes log file).

Definition at line 261 of file fsLog.cpp.

References m_pImpl.

Log_t::Log_t (  )  [protected]

Used only by 'LogImpl_t'.

Definition at line 256 of file fsLog.cpp.

fs::sys::Log_t::Log_t ( const Log_t  )  [private]

No copy.


Member Function Documentation

Log_t& fs::sys::Log_t::operator= ( const Log_t  )  [private]

No assignment.

void Log_t::Push ( const char *  pszFmt,
  ... 
)

Logs a formated string ('printf' style).

Note:
If the resulting formated message exceeds certain fixed length, it is truncated. Note that PushLn is not limited in this way. Push is not a virtual member function so the code is executed according to the static binding...

Todo:
Consider portability of _vsnprintf.

Definition at line 273 of file fsLog.cpp.

References FS_ASSERT_MSG, m_pImpl, and PushLn().

Here is the call graph for this function:

void Log_t::PushLn ( const char *  pszText,
bool  bMsgBrk = false 
) [protected, virtual]

Logs a text line.

Reimplemented in fs::sys::LogImpl_t.

Definition at line 352 of file fsLog.cpp.

References FS_ASSERT_MSG, m_pImpl, and PushLn().

Here is the call graph for this function:

void Log_t::RegSrc ( Log_t pSrc,
bool  bReg = true 
) [protected, virtual]

Links / unlinks log instances.

Reimplemented in fs::sys::LogImpl_t.

Definition at line 366 of file fsLog.cpp.

References FS_ASSERT_MSG, m_pImpl, and RegSrc().

Here is the call graph for this function:

void Log_t::SetTgt ( Log_t pTgt  )  [virtual]

Sets a new target log (dumps history, redirects future records).

Parameters:
pTgt A new log target or 0 to reset current link.

Reimplemented in fs::sys::LogImpl_t.

Examples:
_tests/fsLog/main.cpp.

Definition at line 360 of file fsLog.cpp.

References FS_ASSERT_MSG, m_pImpl, and SetTgt().

Here is the call graph for this function:


Friends And Related Function Documentation

friend class LogImpl_t [friend]

Definition at line 103 of file fsLog.h.


Member Data Documentation

Log_t* fs::sys::Log_t::m_pImpl [private]

The PIPML idiom is used.

Definition at line 116 of file fsLog.h.


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

FipS' Code (Thu Feb 15 22:43:55 2007) - (c) Filip STOKLAS (FipS) - [ www ] [ Guest Book ]