Open
Graph Drawing
Framework

 v.2010.10
 

Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes

ogdf::Logger Class Reference

Centralized global and local logging facility working on streams like cout. More...

#include <ogdf/basic/Logger.h>

Inheritance diagram for ogdf::Logger:
ogdf::SubgraphPlanarizer

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:

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 119 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 123 of file Logger.h.

(local) log-modes (see class description)

Enumerator:
LM_GLOBAL 
LM_GLOBALLOG 
LM_LOG 
LM_STATISTIC 

Definition at line 125 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 129 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 132 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 135 of file Logger.h.

ogdf::Logger::Logger ( LogMode  m,
Level  l 
) [inline]

creates a new Logger-object with given log-mode and given local log-level

Definition at line 138 of file Logger.h.


Member Function Documentation

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 210 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 218 of file Logger.h.

std::ostream& ogdf::Logger::fout (  )  const [inline]

stream for forced output (local)

Definition at line 153 of file Logger.h.

static Level ogdf::Logger::globalLogLevel (  )  [inline, static]

gives the local log-level

Definition at line 191 of file Logger.h.

static void ogdf::Logger::globalLogLevel ( Level  l  )  [inline, static]

sets the global log-level

Definition at line 193 of file Logger.h.

static Level ogdf::Logger::globalMinimumLogLevel (  )  [inline, static]

gives the globally minimally required log-level

Definition at line 196 of file Logger.h.

static void ogdf::Logger::globalMinimumLogLevel ( Level  l  )  [inline, static]

sets the globally minimally required log-level

Definition at line 198 of file Logger.h.

static void ogdf::Logger::globalStatisticMode ( bool  s  )  [inline, static]

sets whether we are globally in statistic mode

Definition at line 203 of file Logger.h.

static bool ogdf::Logger::globalStatisticMode (  )  [inline, static]

returns true if we are globally in statistic mode

Definition at line 201 of file Logger.h.

void ogdf::Logger::localLogLevel ( Level  l  )  [inline]

sets the local log-level

Definition at line 177 of file Logger.h.

Level ogdf::Logger::localLogLevel (  )  const [inline]

gives the local log-level

Definition at line 173 of file Logger.h.

LogMode ogdf::Logger::localLogMode (  )  const [inline]

gives the local log-mode

Definition at line 181 of file Logger.h.

void ogdf::Logger::localLogMode ( LogMode  m  )  [inline]

sets the local log-mode

Definition at line 185 of file Logger.h.

std::ostream& ogdf::Logger::lout ( Level  l = LL_DEFAULT  )  const [inline]

stream for logging-output (local)

Definition at line 143 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 206 of file Logger.h.

static std::ostream& ogdf::Logger::sfout (  )  [inline, static]

stream for forced output (global)

Definition at line 167 of file Logger.h.

static std::ostream& ogdf::Logger::slout ( Level  l = LL_DEFAULT  )  [inline, static]

stream for logging-output (global)

Definition at line 159 of file Logger.h.

std::ostream& ogdf::Logger::sout (  )  const [inline]

stream for statistic-output (local)

Definition at line 149 of file Logger.h.

static std::ostream& ogdf::Logger::ssout (  )  [inline, static]

stream for statistic-output (global)

Definition at line 163 of file Logger.h.


Member Data Documentation

Definition at line 227 of file Logger.h.

bool ogdf::Logger::m_globalstatisticmode [static, private]

Definition at line 229 of file Logger.h.

Definition at line 231 of file Logger.h.

Definition at line 232 of file Logger.h.

Definition at line 228 of file Logger.h.

std::ostream ogdf::Logger::nirvana [static, private]

Definition at line 224 of file Logger.h.

std::ostream* ogdf::Logger::world [static, private]

Definition at line 225 of file Logger.h.


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