Classes | Public Member Functions | Static Public Member Functions | List of all members
booster::log::logger Class Reference

This is the central class that manages all logging operations. More...

#include <booster/booster/log.h>

Inheritance diagram for booster::log::logger:

Public Member Functions

bool should_be_logged (level_type level, char const *module)
void set_log_level (level_type level, char const *module)
void reset_log_level (char const *module)
void set_default_level (level_type level)
void add_sink (shared_ptr< sink > const &s)
void remove_sink (weak_ptr< sink > const &s)
void remove_all_sinks ()
void log (message const &)

Static Public Member Functions

static loggerinstance ()
static char const * level_to_string (level_type level)
static level_type string_to_level (std::string const &)

Detailed Description

This is the central class that manages all logging operations.

This is singleton, you access it only via instance() static member function.

This class is thread safe

Member Function Documentation

void booster::log::logger::add_sink ( shared_ptr< sink > const &  s)

Add new logging sink - the target that receives messages. It is defined by it's pointer.

If you plan to remove it, keep the pointer on such logger.

static logger& booster::log::logger::instance ( )

Get the instance of the logger

static char const* booster::log::logger::level_to_string ( level_type  level)

Get convert the severity level to string

void booster::log::logger::log ( message const &  )

Send a message to the log, note, the message is sent regardless of its severity, use should_be_logged before you create the message

void booster::log::logger::remove_all_sinks ( )

Remove all logging sinks from the logger

void booster::log::logger::remove_sink ( weak_ptr< sink > const &  s)

Remove a logging sink using its pointer. Note it is enough to keep weak pointer on it allowing the logger to destroy the sink.

void booster::log::logger::reset_log_level ( char const *  module)

Reset module's logging severity to default

void booster::log::logger::set_default_level ( level_type  level)

Set default logging level severity

void booster::log::logger::set_log_level ( level_type  level,
char const *  module 

Set specific severity level level for a module module. It would be logged with different logging level then others.

Note: module string should remain valid all the time this log level is used. It is better to use static strings for these purposes

bool booster::log::logger::should_be_logged ( level_type  level,
char const *  module 

Test if the message with severity level level of module module should be logged. This is generally called before preparing a message in order to prevent logging messages that shouldn't be logged

static level_type booster::log::logger::string_to_level ( std::string const &  )

Convert string to severity level, if the string is invalid, std::invalid_argument is thrown

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