pflib v3.9.0-rc3-11-g2537d8f
Pretty Fine HGCROC Interaction Library
Loading...
Searching...
No Matches
pflib::logging Namespace Reference

hold logging infrastructure in namespace More...

Classes

struct  fixture
 a "fixture" that opens the logging when it is created and closes the logging when it is destroyed. More...
 
class  MessageFormatter
 

Typedefs

using logger
 our logger type
 

Enumerations

enum  level {
  trace = -1 , debug = 0 , info = 1 , warn = 2 ,
  error = 3 , fatal = 4
}
 logging severity labels and their corresponding integers
 

Functions

level convert (int i_lvl)
 convert an integer to the severity level enum
 
logger get (const std::string &name)
 Gets a logger with the input name for its channel.
 
template<typename T >
const T & safe_extract (boost::log::attribute_value attr)
 Safely extract a value from the Boost.Log attribute.
 
void open (bool color)
 Initialize the logging backend.
 
void set (level lvl, const std::string &only="")
 Change the level for the logs.
 
void close ()
 Close up the logging.
 

Variables

static level default_level = level::info
 the default level to apply regardless of settings
 
static std::unordered_map< std::string, levelcustom_levels
 custom levels to apply to specific channels
 

Detailed Description

hold logging infrastructure in namespace

Typedef Documentation

◆ logger

Initial value:
boost::log::sources::severity_channel_logger_mt<level, std::string>

our logger type

holds a severity level and a channel name in addition to the other default attributes.

Function Documentation

◆ convert()

level pflib::logging::convert ( int i_lvl)

convert an integer to the severity level enum

Any integer below -1 is set to trace and any integer above four is set to fatal.

Parameters
[in]i_lvlinteger level to be converted
Returns
converted enum level

◆ get()

logger pflib::logging::get ( const std::string & name)

Gets a logger with the input name for its channel.

We maintain a cache of channel-names to loggers so that multiple locations can share the same channel; however, the calls to this function should be minimized in order to avoid wasting time looking up the logger in the cache, making copies of a logger, or creating a new one.

Parameters
namename of this logging channel
Returns
logger with the input channel name

◆ open()

void pflib::logging::open ( bool color)

Initialize the logging backend.

This function sets up the sinks for the logs (e.g. terminal output) and sets the format and filtering.

The formatting is set once and can support coloring the messages using ANSI escape sequences.

◆ safe_extract()

template<typename T >
const T & pflib::logging::safe_extract ( boost::log::attribute_value attr)

Safely extract a value from the Boost.Log attribute.

If the attribute has not been set, then we return a default constructed version of the value.

◆ set()

void pflib::logging::set ( level lvl,
const std::string & only = "" )

Change the level for the logs.

Parameters
[in]lvllevel (and above) to include in messages
[in]onlychannel name to apply the level to