ogdf::Logger Class Reference
Centralized global and local logging facility working on streams like cout.
More...
#include <Logger.h>
List of all members.
|
Public Types |
| enum | Level {
LL_MINOR,
LL_MEDIUM,
LL_DEFAULT,
LL_HIGH,
LL_ALARM,
LL_FORCE
} |
| | supported log-levels from lowest to highest improtance More...
|
| enum | LogMode { LM_GLOBAL,
LM_GLOBALLOG,
LM_LOG,
LM_STATISTIC
} |
| | (local) log-modes (see class description) More...
|
Public Member Functions |
| | Logger () |
| | creates a new Logger-object with LM_GLOBAL and local log-level equal globalLogLevel
|
| | Logger (LogMode m) |
| | creates a new Logger-object with given log-mode and local log-level equal globalLogLevel
|
| | Logger (Level l) |
| | creates a new Logger-object with LM_GLOBAL and given local log-level
|
| | Logger (LogMode m, Level l) |
| | creates a new Logger-object with given log-mode and given local log-level
|
| std::ostream & | lout (Level l=LL_DEFAULT) const |
| | stream for logging-output (local)
|
| std::ostream & | sout () const |
| | stream for statistic-output (local)
|
| std::ostream & | fout () const |
| | stream for forced output (local)
|
| Level | localLogLevel () const |
| | gives the local log-level
|
| void | localLogLevel (Level l) |
| | sets the local log-level
|
| LogMode | localLogMode () const |
| | gives the local log-mode
|
| void | localLogMode (LogMode m) |
| | sets the local log-mode
|
| Level | effectiveLogLevel () const |
| | obtain the effective log-level for the Logger-object (i.e., resolve the depenancies on the global settings)
|
| bool | effectiveStatisticMode () const |
| | returns true if the Logger-object is effectively in statistic-mode (as this might be depending on the global settings)
|
Static Public Member Functions |
| static std::ostream & | slout (Level l=LL_DEFAULT) |
| | stream for logging-output (global)
|
| static std::ostream & | ssout () |
| | stream for statistic-output (global)
|
| static std::ostream & | sfout () |
| | stream for forced output (global)
|
| static Level | globalLogLevel () |
| | gives the local log-level
|
| static void | globalLogLevel (Level l) |
| | sets the global log-level
|
| static Level | globalMinimumLogLevel () |
| | gives the globally minimally required log-level
|
| static void | globalMinimumLogLevel (Level l) |
| | sets the globally minimally required log-level
|
| static bool | globalStatisticMode () |
| | returns true if we are globally in statistic mode
|
| static void | globalStatisticMode (bool s) |
| | sets whether we are globally in statistic mode
|
| static void | setWorldStream (std::ostream &o) |
| | change the stream to which allowed output is written (by default: cout)
|
Private Attributes |
| Level | m_loglevel |
| LogMode | m_logmode |
Static Private Attributes |
| static std::ostream | nirvana |
| static std::ostream * | world |
| static Level | m_globalloglevel |
| static Level | m_minimumloglevel |
| static bool | m_globalstatisticmode |
Detailed Description
Centralized global and local logging facility working on streams like cout.
The Logger class is a centralized logging environment with 2x2 different use-cases working together. All generated output is sent into the world-stream, i.e., cout, if not set otherwise.
Logging vs. Statistic: The Logger differentiates between logging and statistic mode. When in logging mode, only the output written via the lout()/slout() commands is written to the world stream (according to loglevels). When in statistic mode, only the output of the sout()/ssout() commands is written. (Sidenote: there is also a forced output fout()/sfout() which is written independent on the current mode).
The idea of these two modi is that one can augment the code with output which is interesting in the normal computation mode via lout, but the same algorithm can also be run given tabular statistic-lines when e.g. batch-testing the algorithm on a set of benchmark instances.
Global vs. Local: You can choose to use the Logging facilities globally via the static outputs (slout(), ssout(), sfout()). Thereby the global log-level and statistic-mode settings are applied. Alternatively you can create your own Logging object with its own parameters only for your algorithm, and use the object methods lout(), sout(), and fout(). This allows you to turn output on for your own (new) algorithm, but keep the rest of the library silent.
Global Settings: The slout command takes an (optional) parameter given the importance of the output (aka. loglevel). The output is written only if the globalLogLevel is not higher. The method globalStatisticMode turn the statistic-mode on and off (thereby disabling or enabling the logging mode).
Furthermore, we have a globalMinimumLogLevel. This is used to globally forbid any output with too low importance written by any Logger-objects.
Local Settings: A Logger-object has its own set of settings, i.e., its own localLogLevel and an own localLogMode, which can be any of the following:
- LM_LOG: the object is in logging mode, using its own localLogLevel
- LM_STATISTIC: the object is in statistic mode
- LM_GLOBAL: the object is in the same mode as the static Logger-class (i.e., global settings)
- LM_GLOBALLOG: the object is in logging mode, but uses the globalLogLevel
Typical Usage:
The simplest but restricted and verbose usage is to write
Logger::slout() << "1+2=" << (1+2) << endl;
The conceptually easiest and cleanest approach is to augment your algorithm class with a Logger. Multiple inheritance allows this pretty straightforwardly:
class MyAlgorithm : public MyBaseClass, protected Logger {
int myMethod();
}
MyAlgorithm::myMethod() {
lout() << "1+2=" << (1+2) << endl;
}
Definition at line 117 of file Logger.h.
Member Enumeration Documentation
supported log-levels from lowest to highest improtance
- Enumerator:
-
| LL_MINOR |
|
| LL_MEDIUM |
|
| LL_DEFAULT |
|
| LL_HIGH |
|
| LL_ALARM |
|
| LL_FORCE |
|
Definition at line 121 of file Logger.h.
(local) log-modes (see class description)
- Enumerator:
-
| LM_GLOBAL |
|
| LM_GLOBALLOG |
|
| LM_LOG |
|
| LM_STATISTIC |
|
Definition at line 123 of file Logger.h.
Constructor & Destructor Documentation
| ogdf::Logger::Logger |
( |
|
) |
[inline] |
creates a new Logger-object with LM_GLOBAL and local log-level equal globalLogLevel
Definition at line 127 of file Logger.h.
| ogdf::Logger::Logger |
( |
LogMode |
m |
) |
[inline] |
creates a new Logger-object with given log-mode and local log-level equal globalLogLevel
Definition at line 130 of file Logger.h.
| ogdf::Logger::Logger |
( |
Level |
l |
) |
[inline] |
creates a new Logger-object with LM_GLOBAL and given local log-level
Definition at line 133 of file Logger.h.
creates a new Logger-object with given log-mode and given local log-level
Definition at line 136 of file Logger.h.
Member Function Documentation
| std::ostream& ogdf::Logger::lout |
( |
Level |
l = LL_DEFAULT |
) |
const [inline] |
stream for logging-output (local)
Definition at line 141 of file Logger.h.
| std::ostream& ogdf::Logger::sout |
( |
|
) |
const [inline] |
stream for statistic-output (local)
Definition at line 147 of file Logger.h.
| std::ostream& ogdf::Logger::fout |
( |
|
) |
const [inline] |
stream for forced output (local)
Definition at line 151 of file Logger.h.
| static std::ostream& ogdf::Logger::slout |
( |
Level |
l = LL_DEFAULT |
) |
[inline, static] |
stream for logging-output (global)
Definition at line 157 of file Logger.h.
| static std::ostream& ogdf::Logger::ssout |
( |
|
) |
[inline, static] |
stream for statistic-output (global)
Definition at line 161 of file Logger.h.
| static std::ostream& ogdf::Logger::sfout |
( |
|
) |
[inline, static] |
stream for forced output (global)
Definition at line 165 of file Logger.h.
| Level ogdf::Logger::localLogLevel |
( |
|
) |
const [inline] |
gives the local log-level
Definition at line 171 of file Logger.h.
| void ogdf::Logger::localLogLevel |
( |
Level |
l |
) |
[inline] |
sets the local log-level
Definition at line 175 of file Logger.h.
| LogMode ogdf::Logger::localLogMode |
( |
|
) |
const [inline] |
gives the local log-mode
Definition at line 179 of file Logger.h.
| void ogdf::Logger::localLogMode |
( |
LogMode |
m |
) |
[inline] |
sets the local log-mode
Definition at line 183 of file Logger.h.
| static Level ogdf::Logger::globalLogLevel |
( |
|
) |
[inline, static] |
gives the local log-level
Definition at line 189 of file Logger.h.
| static void ogdf::Logger::globalLogLevel |
( |
Level |
l |
) |
[inline, static] |
sets the global log-level
Definition at line 191 of file Logger.h.
| static Level ogdf::Logger::globalMinimumLogLevel |
( |
|
) |
[inline, static] |
gives the globally minimally required log-level
Definition at line 194 of file Logger.h.
| static void ogdf::Logger::globalMinimumLogLevel |
( |
Level |
l |
) |
[inline, static] |
sets the globally minimally required log-level
Definition at line 196 of file Logger.h.
| static bool ogdf::Logger::globalStatisticMode |
( |
|
) |
[inline, static] |
returns true if we are globally in statistic mode
Definition at line 199 of file Logger.h.
| static void ogdf::Logger::globalStatisticMode |
( |
bool |
s |
) |
[inline, static] |
sets whether we are globally in statistic mode
Definition at line 201 of file Logger.h.
| static void ogdf::Logger::setWorldStream |
( |
std::ostream & |
o |
) |
[inline, static] |
change the stream to which allowed output is written (by default: cout)
Definition at line 204 of file Logger.h.
| Level ogdf::Logger::effectiveLogLevel |
( |
|
) |
const [inline] |
obtain the effective log-level for the Logger-object (i.e., resolve the depenancies on the global settings)
Definition at line 208 of file Logger.h.
| bool ogdf::Logger::effectiveStatisticMode |
( |
|
) |
const [inline] |
returns true if the Logger-object is effectively in statistic-mode (as this might be depending on the global settings)
Definition at line 216 of file Logger.h.
Member Data Documentation
The documentation for this class was generated from the following file:
© 1999-2007 by oreas GmbH, © 2005-2007 by University Dortmund and University Cologne.
Generated on Thu Nov 22 19:40:08 2007 by doxygen 1.5.4.