libpsynth 0.2.1
Public Types | Public Member Functions | Static Public Member Functions
psynth::base::log Class Reference

A logger node. More...

#include <logger.hpp>

Inheritance diagram for psynth::base::log:
Inheritance graph
[legend]
Collaboration diagram for psynth::base::log:
Collaboration graph
[legend]

List of all members.

Public Types

enum  level {
  debug, info, warning, error,
  fatal
}
 The message relevance. More...

Public Member Functions

 log ()
 Constructor.
 ~log ()
 Destructor.
void add_sink (log_sink_ptr d)
 Attachs a sink to this node.
void del_sink (log_sink_ptr d)
 Dettachs a sink from this node.
void operator() (const std::string &child, int level, const std::string &msg)
 Logs a message in a child of this node and all its parents.
void operator() (int level, const std::string &msg)
 Log a message into this node.
log_stream_adapter_wrapper stream ()
 Returns a stream object that can be used to send messages to the log in a iostreams fashion.

Static Public Member Functions

static const char * level_name (int level)
 Returns a string version of each level name.

Detailed Description

A logger node.

The log structure is actually a tree so log messages can be categorized hierarchically. When a message its logged, the message is propagated by all the log parents so, for example, you can set up your sinks the root node if you want to listen for all messages.

Note:
This class is thread safe.
Todo:
Make thread-safety optional. Note that there are some thread-safety in some corner cases in all the new thread safe classes. Please, take a deep look at it and consider using recursive_mutex as a default.

Member Enumeration Documentation

The message relevance.

Todo:
Make it easier to add custom levels.
Enumerator:
debug 

Debug information interesting only for devels.

info 

Usefull info to the user.

warning 

A problem that may cause inconvenience.

error 

A problem that definetly causes inconvenience.

fatal 

A problem that from which we cannot recover.


Constructor & Destructor Documentation

psynth::base::log::log ( ) [inline]

Constructor.

psynth::base::log::~log ( )

Destructor.


Member Function Documentation

void psynth::base::log::add_sink ( log_sink_ptr  d)

Attachs a sink to this node.

Parameters:
dThe sink that we want to dump this log's messages.
void psynth::base::log::del_sink ( log_sink_ptr  d)

Dettachs a sink from this node.

Parameters:
dThe sink we don't want to dump massages of this log anymore.
static const char* psynth::base::log::level_name ( int  level) [inline, static]

Returns a string version of each level name.

Parameters:
levelThe level of which we want to now its string name.
void psynth::base::log::operator() ( const std::string &  child,
int  level,
const std::string &  msg 
) [inline]

Logs a message in a child of this node and all its parents.

Parameters:
childThe child in which we want to log the message.
levelThe relevance of this message.
msgThe message to log.
void psynth::base::log::operator() ( int  level,
const std::string &  msg 
) [inline]

Log a message into this node.

Parameters:
levelThe relevance of this message.
msgThe message to log.
log_stream_adapter_wrapper psynth::base::log::stream ( ) [inline]

Returns a stream object that can be used to send messages to the log in a iostreams fashion.


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