OSB_LIB::LogBase Class Reference

Inheritance diagram for OSB_LIB::LogBase:

Inheritance graph
[legend]
Collaboration diagram for OSB_LIB::LogBase:

Collaboration graph
[legend]
List of all members.

Detailed Description

Interface definition for the logging implementation.

Logging levels

Design comments
Because of the output operator template there is unfortunately no reasonable way to hide (and isolate) the optional logging to a secondary output stream.
The following however can be implemented in the concrete implementations of the interface:

The current design is weak because the class controls both, access to the output streams and the output format (the header of the logged message). Two new classes may replace the current class in a future version: LogAccess and LogFormat; AFAICS today, the interface of the purely static class Log however should not be affected.

Note:
The implementation of the virtual functions should not write to plog() (and slog()) directly, but redirect all output to itself:
      LogBase& ConsoleLog::nl()
      {
          *this << '\n';
          return *this;
      }
This way the output operators take automatically care of the log level and the optional outout to the secondary stream.

Definition at line 99 of file osblog.h.

Public Member Functions

Start a logging message:
All functions call start() with the appropriate level.

Output manipulators.
IO stream manipulators.
Application interface:

Protected Member Functions

Protected Attributes

Classes


Constructor & Destructor Documentation

OSB_LIB::LogBase::LogBase ( int  logLevel  )  [explicit]

Constructor with log level.

virtual OSB_LIB::LogBase::~LogBase (  )  [virtual]

Virtual destructor.


Member Function Documentation

LogBase & OSB_LIB::LogBase::debug ( int  level  )  [inline]

Start a debugging message.

Parameters:
level Debugging level (1-3): 1 corresponds to log level 5.
The library only uses debug levels 1-3. An application may use higher levels.

Definition at line 626 of file osblog.h.

References start().

Referenced by OSB_LIB::Log::debug().

virtual void OSB_LIB::LogBase::elog (  )  [pure virtual]

End the logging message with a new-line.

Attention:
A concrete implementation that uses locking should unlock in this method.

Implemented in OSB_LIB::ConsoleLog.

Referenced by OSB_LIB::Log::elog().

virtual void OSB_LIB::LogBase::endlog (  )  [pure virtual]

End the logging message without a new-line.

Attention:
A concrete implementation that uses locking should unlock in this method.

Implemented in OSB_LIB::ConsoleLog.

Referenced by OSB_LIB::Log::endlog().

LogBase & OSB_LIB::LogBase::error (  )  [inline]

Start an error message.

Definition at line 606 of file osblog.h.

References start().

Referenced by OSB_LIB::Log::error().

LogBase & OSB_LIB::LogBase::fatal (  )  [inline]

Start a fatal error message.

Definition at line 601 of file osblog.h.

References start().

Referenced by OSB_LIB::Log::fatal().

virtual LogBase& OSB_LIB::LogBase::head ( char  filler  )  [pure virtual]

Fill the start a new line with a character.

Parameters:
filler Filler to use.
See Log::head() for an usage example.

Implemented in OSB_LIB::ConsoleLog.

Referenced by operator<<().

LogBase & OSB_LIB::LogBase::info (  )  [inline]

Start a normal message.

Definition at line 616 of file osblog.h.

References start().

Referenced by OSB_LIB::Log::info().

virtual int OSB_LIB::LogBase::logLevel (  )  const [virtual]

Get the current log level.

Attention:
A concrete implementation that uses locking should overwrite this method.

Referenced by OSB_LIB::Log::logLevel().

bool OSB_LIB::LogBase::mustLog (  )  const [inline, protected]

Write current log message?

Returns:
true if logLevel_ is -1 or >= curLevel_.
Locking
The base class calls this member function only from output operators that write to plog().

Definition at line 631 of file osblog.h.

References curLevel_, and logLevel_.

Referenced by operator<<().

virtual LogBase& OSB_LIB::LogBase::nl (  )  [pure virtual]

Start a new line.

Writes a '\n' and the indent for the next line.
If you want to avoid the indent output the newline character directly.

Implemented in OSB_LIB::ConsoleLog.

Referenced by OSB_LIB::Log::nl().

LogBase & OSB_LIB::LogBase::operator<< ( std::ios_base &(*)(std::ios_base &)  func  )  [inline]

Definition at line 705 of file osblog.h.

References mustLog(), plog(), slog(), and verbose_.

LogBase & OSB_LIB::LogBase::operator<< ( std::ios &(*)(std::ios &)  func  )  [inline]

Definition at line 691 of file osblog.h.

References mustLog(), plog(), slog(), and verbose_.

LogBase & OSB_LIB::LogBase::operator<< ( std::ostream &(*)(std::ostream &)  func  )  [inline]

Definition at line 677 of file osblog.h.

References mustLog(), plog(), slog(), and verbose_.

template<typename T>
LogBase & OSB_LIB::LogBase::operator<< ( const T &  t  )  [inline]

Output operator for arbitrary types and objects.

Definition at line 660 of file osblog.h.

References indent_, mustLog(), plog(), slog(), useIndent_, and verbose_.

LogBase & OSB_LIB::LogBase::operator<< ( const HeadFiller filler  )  [inline]

Start a new line and fill its head with a character.

Definition at line 652 of file osblog.h.

References OSB_LIB::LogBase::HeadFiller::filler_, and head().

LogBase & OSB_LIB::LogBase::operator<< ( LogBase &(*)(LogBase &)  func  )  [inline]

Other manipulators of Log.

Definition at line 645 of file osblog.h.

void OSB_LIB::LogBase::operator<< ( void(*)(LogBase &)  func  )  [inline]

For Log::elog() and Log::endlog().

Definition at line 638 of file osblog.h.

virtual std::ostream& OSB_LIB::LogBase::plog (  )  [protected, pure virtual]

Get the primary output stream.

Implemented in OSB_LIB::ConsoleLog.

Referenced by operator<<().

LogBase & OSB_LIB::LogBase::raw ( int  level  )  [inline]

Start a message without standard header.

Definition at line 621 of file osblog.h.

References start().

Referenced by OSB_LIB::Log::raw().

virtual void OSB_LIB::LogBase::setLevel ( int  logLevel  )  [virtual]

Set the log level.

Parameters:
logLevel New log level to be used.
Attention:
A concrete implementation that uses locking should overwrite this method.

Referenced by OSB_LIB::Log::setLevel().

virtual void OSB_LIB::LogBase::setVerbose ( bool  on  )  [virtual]

Set verbose flag.

Attention:
A concrete implementation that uses locking should overwrite this method.

Referenced by OSB_LIB::Log::setVerbose().

virtual std::ostream* OSB_LIB::LogBase::slog (  )  [protected, pure virtual]

Get the secondary output stream.

Implemented in OSB_LIB::ConsoleLog.

Referenced by operator<<().

virtual LogBase& OSB_LIB::LogBase::start ( int  level,
bool  noHead = false 
) [protected, pure virtual]

Start a log message.

Parameters:
level Log level as decscribed above.
noHead Flag to suppress message header and indentation.
Concrete implementations should set curLevel_ to level, else all messages will be output.
Because of locking issues this can not be done in the base class.

Attention:
A concrete implementation that uses locking should lock in this method.

Implemented in OSB_LIB::ConsoleLog.

Referenced by debug(), error(), fatal(), info(), raw(), and warn().

virtual bool OSB_LIB::LogBase::verbose (  )  const [virtual]

Verbose (duplicate) messages on slog()?

Attention:
A concrete implementation that uses locking should overwrite this method.

Referenced by OSB_LIB::Log::verbose().

LogBase & OSB_LIB::LogBase::warn (  )  [inline]

Start a warning.

Definition at line 611 of file osblog.h.

References start().

Referenced by OSB_LIB::Log::warn().


Member Data Documentation

int OSB_LIB::LogBase::curLevel_ [protected]

The log level of the current message.

Definition at line 287 of file osblog.h.

Referenced by mustLog().

std::string OSB_LIB::LogBase::indent_ [protected]

Indent of next output.

Definition at line 295 of file osblog.h.

Referenced by operator<<().

int OSB_LIB::LogBase::logLevel_ [protected]

The log level: messages with a greater level are suppressed.

-1 means that all messages are output.

Definition at line 285 of file osblog.h.

Referenced by mustLog().

bool OSB_LIB::LogBase::noHead_ [protected]

Flag to suppress message header and indentation.

Definition at line 291 of file osblog.h.

bool OSB_LIB::LogBase::useIndent_ [protected]

Flag to print indent_.

Definition at line 293 of file osblog.h.

Referenced by operator<<().

bool OSB_LIB::LogBase::verbose_ [protected]

Flag to duplicate messages on slog().

Definition at line 289 of file osblog.h.

Referenced by operator<<().


The documentation for this class was generated from the following file:
Generated on Sat Sep 2 14:12:14 2006 for OSB Library by  doxygen 1.4.7