TARAXA
taraxa::logger Namespace Reference

Classes

class  Config
 

Typedefs

using Logger = boost::log::sources::severity_channel_logger_mt<>
 

Enumerations

enum  Verbosity {
  Silent = -1 , Error = 0 , Warning = 1 , Info = 2 ,
  Debug = 3 , Trace = 4
}
 

Functions

Logger createLogger (Verbosity verboseLevel, const std::string &channel, const addr_t &node_id)
 Creates thread-safe severity channel logger. More...
 
Config createDefaultLoggingConfig ()
 Creates default logging config. More...
 
void InitLogging (Config &logging_config, const addr_t &node_id)
 Initializes logging according to the provided logging_config. More...
 
Verbosity stringToVerbosity (std::string _verbosity)
 Transforms string verbosity to Verbosity enum. More...
 

Typedef Documentation

◆ Logger

using taraxa::logger::Logger = typedef boost::log::sources::severity_channel_logger_mt<>

Enumeration Type Documentation

◆ Verbosity

Enumerator
Silent 
Error 
Warning 
Info 
Debug 
Trace 

Function Documentation

◆ createDefaultLoggingConfig()

Config taraxa::logger::createDefaultLoggingConfig ( )

Creates default logging config.

Returns
logger::Config

◆ createLogger()

Logger taraxa::logger::createLogger ( Verbosity  verboseLevel,
const std::string &  channel,
const addr_t node_id 
)

Creates thread-safe severity channel logger.

Note
To control logging in terms of where log messages are forwarded(console/file), severity filter etc..., see functions createDefaultLoggingConfig and InitLogging. Usage example:

// Creates logging config auto logging_config = createDefaultLoggingConfig(); logging_config.verbosity = logger::Verbosity::Error; logging_config.channels["SAMPLE_CHANNEL"] = logger::Verbosity::Error;

// Initializes logging according to the provided config InitLogging(logging_config);

addr_t node_addr;

// Creates error logger auto logger = createLogger(logger::Verbosity::Error, "SAMPLE_CHANNEL", node_addr)

LOG(logger) << "sample message";

Note
see macros LOG_OBJECTS_DEFINE, LOG_OBJECTS_CREATE, LOG
Parameters
verboseLevel
_channel
node_id
Returns
Logger object

◆ InitLogging()

void taraxa::logger::InitLogging ( Config logging_config,
const addr_t node_id 
)

Initializes logging according to the provided logging_config.

Parameters
logging_config
node_id

◆ stringToVerbosity()

Verbosity taraxa::logger::stringToVerbosity ( std::string  _verbosity)

Transforms string verbosity to Verbosity enum.

Parameters
_verbosity
Returns
Verbosity enum