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.
LogBase& ConsoleLog::nl() { *this << '\n'; return *this; }
Definition at line 99 of file osblog.h.
OSB_LIB::LogBase::LogBase | ( | int | logLevel | ) | [explicit] |
Constructor with log level.
virtual OSB_LIB::LogBase::~LogBase | ( | ) | [virtual] |
Virtual destructor.
LogBase & OSB_LIB::LogBase::debug | ( | int | level | ) | [inline] |
Start a debugging message.
level | Debugging level (1-3): 1 corresponds to log level 5. |
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.
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.
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.
filler | Filler to use. |
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.
Referenced by OSB_LIB::Log::logLevel().
bool OSB_LIB::LogBase::mustLog | ( | ) | const [inline, protected] |
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] |
LogBase & OSB_LIB::LogBase::operator<< | ( | std::ios &(*)(std::ios &) | func | ) | [inline] |
LogBase & OSB_LIB::LogBase::operator<< | ( | std::ostream &(*)(std::ostream &) | func | ) | [inline] |
LogBase & OSB_LIB::LogBase::operator<< | ( | const T & | t | ) | [inline] |
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().
void OSB_LIB::LogBase::operator<< | ( | void(*)(LogBase &) | func | ) | [inline] |
virtual std::ostream& OSB_LIB::LogBase::plog | ( | ) | [protected, pure virtual] |
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.
logLevel | New log level to be used. |
Referenced by OSB_LIB::Log::setLevel().
virtual void OSB_LIB::LogBase::setVerbose | ( | bool | on | ) | [virtual] |
Set verbose flag.
Referenced by OSB_LIB::Log::setVerbose().
virtual std::ostream* OSB_LIB::LogBase::slog | ( | ) | [protected, pure virtual] |
virtual LogBase& OSB_LIB::LogBase::start | ( | int | level, | |
bool | noHead = false | |||
) | [protected, pure virtual] |
Start a log message.
level | Log level as decscribed above. | |
noHead | Flag to suppress message header and indentation. |
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()?
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().
int OSB_LIB::LogBase::curLevel_ [protected] |
std::string OSB_LIB::LogBase::indent_ [protected] |
int OSB_LIB::LogBase::logLevel_ [protected] |
bool OSB_LIB::LogBase::noHead_ [protected] |
bool OSB_LIB::LogBase::useIndent_ [protected] |
bool OSB_LIB::LogBase::verbose_ [protected] |
Flag to duplicate messages on slog().
Definition at line 289 of file osblog.h.
Referenced by operator<<().