PDI 1.7.1

the PDI data interface

PDI::Logger Class Reference

Wrapper for spdlog::logger with additional pattern getter method. More...

Public Member Functions

 Logger ()=default
 Creates new empty logger.
 
 Logger (const std::string &logger_name, PC_tree_t config, spdlog::level::level_enum level=spdlog::level::info)
 Creates new logger.
 
 Logger (Logger &parent_logger, const std::string &logger_name, PC_tree_t config)
 Creates new logger with parent logger.
 
void setup (const std::string &logger_name, PC_tree_t config, spdlog::level::level_enum level=spdlog::level::info)
 Sets up the logger.
 
void setup (Logger &parent_logger, const std::string &logger_name, PC_tree_t config)
 Sets up the logger with parent logger.
 
void pattern (const std::string &pattern)
 Changes pattern of the logger.
 
void global_pattern (const std::string &pattern)
 Changes pattern of the global logger.
 
void default_pattern (const std::string &pattern)
 Changes default pattern of the logger (won't be updated if current pattern is from config)
 
void add_pattern_block (const std::string &block)
 Add new element to default pattern.
 
void add_pattern_global_block (const std::string &block)
 Add new element to default pattern of the global logger.
 
const std::string & pattern () const
 Returns pattern of the logger.
 
void level (spdlog::level::level_enum log_level)
 Sets logger level.
 
spdlog::level::level_enum level () const
 Returns level of the logger.
 
void evaluate_pattern (Context &ctx) const
 Evaluate pattern.
 
void evaluate_global_pattern (Context &ctx) const
 Evaluate global pattern.
 
template<typename... Args>
void trace (const char *fmt, Args &&... args)
 Writes trace level message.
 
template<typename... Args>
void debug (const char *fmt, Args &&... args)
 Writes debug level message.
 
template<typename... Args>
void info (const char *fmt, Args &&... args)
 Writes info level message.
 
template<typename... Args>
void warn (const char *fmt, Args &&... args)
 Writes warning level message.
 
template<typename... Args>
void error (const char *fmt, Args &&... args)
 Writes error level message.
 
std::shared_ptr< spdlog::logger > real_logger ()
 Returns real spdlog logger.
 

Detailed Description

Wrapper for spdlog::logger with additional pattern getter method.

Constructor & Destructor Documentation

◆ Logger() [1/3]

PDI::Logger::Logger ( )
default

Creates new empty logger.

◆ Logger() [2/3]

PDI::Logger::Logger ( const std::string &  logger_name,
PC_tree_t  config,
spdlog::level::level_enum  level = spdlog::level::info 
)

Creates new logger.

Parameters
[in]logger_namelogger name that will be displayed
[in]configconfiguration tree from config file
[in]leveldefault level of the logger

◆ Logger() [3/3]

PDI::Logger::Logger ( Logger parent_logger,
const std::string &  logger_name,
PC_tree_t  config 
)

Creates new logger with parent logger.

Parameters
[in]parent_loggerthe logger to observe if default pattern has changed
[in]logger_namelogger name that will be displayed
[in]configconfiguration tree from config file

Loggers can inherit block structure from parent_logger. When inherited, pattern and level of the parent will be set as default pattern and level of the child. The pattern and level are inherited if they are not set in child config file. For now it works with plugin loggers. PDI core logger is the parent and plugin logger is the child.

Member Function Documentation

◆ setup() [1/2]

void PDI::Logger::setup ( const std::string &  logger_name,
PC_tree_t  config,
spdlog::level::level_enum  level = spdlog::level::info 
)

Sets up the logger.

Parameters
[in]logger_namelogger name that will be displayed
[in]configconfiguration tree from config file
[in]leveldefault level of the logger

◆ setup() [2/2]

void PDI::Logger::setup ( Logger parent_logger,
const std::string &  logger_name,
PC_tree_t  config 
)

Sets up the logger with parent logger.

Parameters
[in]parent_loggerthe logger to observe if default pattern has changed
[in]logger_namelogger name that will be displayed
[in]configconfiguration tree from config file

◆ pattern() [1/2]

void PDI::Logger::pattern ( const std::string &  pattern)

Changes pattern of the logger.

Parameters
[in]patternpattern to set

◆ global_pattern()

void PDI::Logger::global_pattern ( const std::string &  pattern)

Changes pattern of the global logger.

Parameters
[in]patternpattern to set

The global logger is the logger without a parent.

◆ default_pattern()

void PDI::Logger::default_pattern ( const std::string &  pattern)

Changes default pattern of the logger (won't be updated if current pattern is from config)

Parameters
[in]patternpattern to set

◆ add_pattern_block()

void PDI::Logger::add_pattern_block ( const std::string &  block)

Add new element to default pattern.

Parameters
[in]blocknew string block to add

◆ add_pattern_global_block()

void PDI::Logger::add_pattern_global_block ( const std::string &  block)

Add new element to default pattern of the global logger.

Parameters
[in]blocknew string block to add

Adds block to the pattern of the global logger.

◆ pattern() [2/2]

const std::string & PDI::Logger::pattern ( ) const

Returns pattern of the logger.

Returns
pattern of the logger

◆ level() [1/2]

void PDI::Logger::level ( spdlog::level::level_enum  log_level)

Sets logger level.

Parameters
[in]log_levellevel to set

◆ level() [2/2]

spdlog::level::level_enum PDI::Logger::level ( ) const

Returns level of the logger.

Returns
level of the logger

◆ evaluate_pattern()

void PDI::Logger::evaluate_pattern ( Context ctx) const

Evaluate pattern.

Parameters
[in]ctxthe context in which to evaluate the pattern

Evaluation of the pattern.

◆ evaluate_global_pattern()

void PDI::Logger::evaluate_global_pattern ( Context ctx) const

Evaluate global pattern.

Parameters
[in]ctxthe context in which to evaluate the pattern

Evaluation of the pattern. Used to evaluate parent and child patterns.

◆ trace()

template<typename... Args>
void PDI::Logger::trace ( const char *  fmt,
Args &&...  args 
)
inline

Writes trace level message.

Parameters
[in]fmtfmt formatted string
[in]argsarguments for fmt string

◆ debug()

template<typename... Args>
void PDI::Logger::debug ( const char *  fmt,
Args &&...  args 
)
inline

Writes debug level message.

Parameters
[in]fmtfmt formatted string
[in]argsarguments for fmt string

◆ info()

template<typename... Args>
void PDI::Logger::info ( const char *  fmt,
Args &&...  args 
)
inline

Writes info level message.

Parameters
[in]fmtfmt formatted string
[in]argsarguments for fmt string

◆ warn()

template<typename... Args>
void PDI::Logger::warn ( const char *  fmt,
Args &&...  args 
)
inline

Writes warning level message.

Parameters
[in]fmtfmt formatted string
[in]argsarguments for fmt string

◆ error()

template<typename... Args>
void PDI::Logger::error ( const char *  fmt,
Args &&...  args 
)
inline

Writes error level message.

Parameters
[in]fmtfmt formatted string
[in]argsarguments for fmt string

◆ real_logger()

std::shared_ptr< spdlog::logger > PDI::Logger::real_logger ( )

Returns real spdlog logger.

Returns
spdlog logger

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