Logger Class Reference

#include <logger.h>

Collaboration diagram for Logger:
Collaboration graph
[legend]

List of all members.

Public Types

enum  Level {
  Lvl0, Lvl1, Lvl2, Lvl3,
  Lvl4, Lvl5
}
typedef unsigned long long bitmask
 typedef for a bitmask (long long)
typedef std::string component
 typedef for a component name (std:string)

Public Member Functions

 ~Logger ()
 Destructor.
short getLevel () const
void setLevel (Level lvl)
bool isLogged (bitmask m) const
void registerComponent (component const &comp)
void registerComponents (std::vector< component > const &components)
void setLogged (component const &comp, bool tobelogged)
void log (Level lvl, std::string const &msg) const
void logAll ()
bitmask getMask (component const &comp)

Static Public Member Functions

static Loggerget ()
static void set (Logger *inst)
static int getStackTrace (std::string &s)

Static Public Attributes

static bitmask unregistered
static char * unregisteredname
static Loggerinstance

Private Member Functions

 Logger ()
 Private constructor.
 Logger (Logger const &)
Loggeroperator= (Logger const &)

Private Attributes

short level
 current log level
int size
 number of components that were assigned with a bitmask
bitmask mask
 global bitmask with all registered components
std::map< component, bitmaskmapping
 component name to bitmask mapping

Detailed Description

A Logger class


Member Typedef Documentation

typedef unsigned long long Logger::bitmask

typedef for a bitmask (long long)

typedef std::string Logger::component

typedef for a component name (std:string)


Member Enumeration Documentation

Use the same values for log levels as syslog

Enumerator:
Lvl0 
Lvl1 
Lvl2 
Lvl3 
Lvl4 
Lvl5 

Constructor & Destructor Documentation

Logger::~Logger (  ) 

Destructor.

Logger::Logger (  )  [private]

Private constructor.

Logger::Logger ( Logger const &   )  [private]

Member Function Documentation

static Logger* Logger::get (  )  [inline, static]
Returns:
the singleton instance
short Logger::getLevel (  )  const [inline]
Returns:
the current debug level
bitmask Logger::getMask ( component const &  comp  ) 
Parameters:
comp : component name
Returns:
respectiv bitmask assigned to given component
static int Logger::getStackTrace ( std::string &  s  )  [static]

Build a printable stacktrace. Useful e.g. inside exceptions, to understand where they come from. Note: I don't think that the backtrace() function is thread safe, nor this function Returns the number of backtraces

Parameters:
s : the string that will contain the printable stacktrace
Returns:
the number of stacktraces
bool Logger::isLogged ( bitmask  m  )  const [inline]
Returns:
true if the given component is being logged, false otherwise
void Logger::log ( Level  lvl,
std::string const &  msg 
) const

Logs the message

Parameters:
lvl : log level of the message
component : bitmask assignet to the given component
msg : the message to be logged
void Logger::logAll (  )  [inline]
Parameters:
if true all unregistered components will be logged, if false only registered components will be logged
Logger& Logger::operator= ( Logger const &   )  [private]
void Logger::registerComponent ( component const &  comp  ) 
Parameters:
comp : the component that will be registered for logging
void Logger::registerComponents ( std::vector< component > const &  components  ) 
Parameters:
components : list of components that will be registered for logging
static void Logger::set ( Logger inst  )  [inline, static]
void Logger::setLevel ( Level  lvl  )  [inline]
Parameters:
lvl : the logging level that will be set
void Logger::setLogged ( component const &  comp,
bool  tobelogged 
)

Sets if a component has to be logged or not

Parameters:
comp : the component name
tobelogged : true if we want to log this component

Member Data Documentation

short Logger::level [private]

current log level

std::map<component, bitmask> Logger::mapping [private]

component name to bitmask mapping

bitmask Logger::mask [private]

global bitmask with all registered components

int Logger::size [private]

number of components that were assigned with a bitmask

char* Logger::unregisteredname [static]

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

Generated on 6 Dec 2016 for dmlite by  doxygen 1.6.1