NRP Core  1.4.1
NRPLogger Class Reference

NRP Logging functions. More...

#include <nrp_logger.h>

Public Types

typedef spdlog::level::level_enum level_t
 The wrapper type for log levels. More...
 
using spdlog_out_fcn_t = void(&)(const std::string &)
 Logging function type, is used by Exception. More...
 

Public Member Functions

 NRPLogger (std::string loggerName=_defaultLoggerName.data())
 The creation of the configurable instance of spdlog, that is set to default logger, with default settings. More...
 
 NRPLogger (std::string loggerName, NRPLogger::level_t fileLogLevel, NRPLogger::level_t consoleLogLevel, std::string logDir, bool doSavePars=false)
 The creation of the configurable instance of spdlog, that is set to default logger. More...
 
 ~NRPLogger ()
 
void flush ()
 Flush default logger. More...
 

Static Public Member Functions

static std::string level_to_string (const NRPLogger::level_t &level)
 Wrapper function for converting enumed log level into string. More...
 
static NRPLogger::level_t level_from_string (const std::string &level)
 Wrapper function for getting enumed log level from string. Non-valid string is converted to enum::off. More...
 
static void shutdownDefault ()
 Shutdown default logger. More...
 
static spdlog::logger & nrpLogger ()
 Get default NRPLogger. More...
 
template<typename FormatString , typename... Args>
static void debug (const FormatString &fmt, const Args &...args)
 NRP logging function with message formatting for debug level. More...
 
template<typename FormatString , typename... Args>
static void info (const FormatString &fmt, const Args &...args)
 NRP logging function with message formatting for info level. More...
 
template<typename FormatString , typename... Args>
static void warn (const FormatString &fmt, const Args &...args)
 NRP logging function with message formatting for warning level. More...
 
template<typename FormatString , typename... Args>
static void error (const FormatString &fmt, const Args &...args)
 NRP logging function with message formatting for error level. More...
 
template<typename FormatString , typename... Args>
static void critical (const FormatString &fmt, const Args &...args)
 NRP logging function with message formatting for critical error level. More...
 
template<typename Message >
static void debug (const Message &msg)
 NRP logging function for debug level. More...
 
template<typename Message >
static void info (const Message &msg)
 NRP logging function for info level. More...
 
template<typename Message >
static void warn (const Message &msg)
 NRP logging function for warning level. More...
 
template<typename Message >
static void error (const Message &msg)
 NRP logging function for error level. More...
 
template<typename Message >
static void critical (const Message &msg)
 NRP logging function for critical error level. More...
 

Detailed Description

NRP Logging functions.

Member Typedef Documentation

◆ level_t

typedef spdlog::level::level_enum NRPLogger::level_t

The wrapper type for log levels.

◆ spdlog_out_fcn_t

using NRPLogger::spdlog_out_fcn_t = void (&)(const std::string &)

Logging function type, is used by Exception.

Constructor & Destructor Documentation

◆ NRPLogger() [1/2]

NRPLogger::NRPLogger ( std::string  loggerName = _defaultLoggerName.data())

The creation of the configurable instance of spdlog, that is set to default logger, with default settings.

Parameters
loggerNameThe name of the logger, that is to be displayed in message and placed as log file prefix

◆ NRPLogger() [2/2]

NRPLogger::NRPLogger ( std::string  loggerName,
NRPLogger::level_t  fileLogLevel,
NRPLogger::level_t  consoleLogLevel,
std::string  logDir,
bool  doSavePars = false 
)

The creation of the configurable instance of spdlog, that is set to default logger.

If the \launcher is set true, then the constructor tries to save the logger settings to the shared memory object. Otherwise, the constructor tries to load this settings from the shared memory object. In case of success, these settings are applied to the logger to be created, otherwise the provided settings are used.

Parameters
loggerNameThe name of the logger, that is to be displayed in message and placed as log file prefix
logDirThe location for the log files
fileLogLevelThe minimum log level to be put to the log files
consoleLogLevelThe minimum log level to be printed in console
doSaveParsSave logger parameters to shared memory or not (load them instaed)

◆ ~NRPLogger()

NRPLogger::~NRPLogger ( )

Member Function Documentation

◆ critical() [1/2]

template<typename FormatString , typename... Args>
static void NRPLogger::critical ( const FormatString &  fmt,
const Args &...  args 
)
inlinestatic

NRP logging function with message formatting for critical error level.

Parameters
fmtMessage format string in fmt library style https://fmt.dev/latest/index.html
argsArguments for substitution into format string #fmt

◆ critical() [2/2]

template<typename Message >
static void NRPLogger::critical ( const Message &  msg)
inlinestatic

NRP logging function for critical error level.

Parameters
msgThe message to be logged

◆ debug() [1/2]

template<typename FormatString , typename... Args>
static void NRPLogger::debug ( const FormatString &  fmt,
const Args &...  args 
)
inlinestatic

NRP logging function with message formatting for debug level.

Parameters
fmtMessage format string in fmt library style https://fmt.dev/latest/index.html
argsArguments for substitution into format string #fmt

◆ debug() [2/2]

template<typename Message >
static void NRPLogger::debug ( const Message &  msg)
inlinestatic

NRP logging function for debug level.

Parameters
msgThe message to be logged

◆ error() [1/2]

template<typename FormatString , typename... Args>
static void NRPLogger::error ( const FormatString &  fmt,
const Args &...  args 
)
inlinestatic

NRP logging function with message formatting for error level.

Parameters
fmtMessage format string in fmt library style https://fmt.dev/latest/index.html
argsArguments for substitution into format string #fmt

◆ error() [2/2]

template<typename Message >
static void NRPLogger::error ( const Message &  msg)
inlinestatic

NRP logging function for error level.

Parameters
msgThe message to be logged

◆ flush()

void NRPLogger::flush ( )

Flush default logger.

◆ info() [1/2]

template<typename FormatString , typename... Args>
static void NRPLogger::info ( const FormatString &  fmt,
const Args &...  args 
)
inlinestatic

NRP logging function with message formatting for info level.

Parameters
fmtMessage format string in fmt library style https://fmt.dev/latest/index.html
argsArguments for substitution into format string #fmt

◆ info() [2/2]

template<typename Message >
static void NRPLogger::info ( const Message &  msg)
inlinestatic

NRP logging function for info level.

Parameters
msgThe message to be logged

◆ level_from_string()

static NRPLogger::level_t NRPLogger::level_from_string ( const std::string &  level)
inlinestatic

Wrapper function for getting enumed log level from string. Non-valid string is converted to enum::off.

Parameters
levelThe string representation of the log level

◆ level_to_string()

static std::string NRPLogger::level_to_string ( const NRPLogger::level_t level)
inlinestatic

Wrapper function for converting enumed log level into string.

Parameters
levelThe numbered representation of the log level

◆ nrpLogger()

static spdlog::logger& NRPLogger::nrpLogger ( )
static

Get default NRPLogger.

◆ shutdownDefault()

void NRPLogger::shutdownDefault ( )
static

Shutdown default logger.

◆ warn() [1/2]

template<typename FormatString , typename... Args>
static void NRPLogger::warn ( const FormatString &  fmt,
const Args &...  args 
)
inlinestatic

NRP logging function with message formatting for warning level.

Parameters
fmtMessage format string in fmt library style https://fmt.dev/latest/index.html
argsArguments for substitution into format string #fmt

◆ warn() [2/2]

template<typename Message >
static void NRPLogger::warn ( const Message &  msg)
inlinestatic

NRP logging function for warning level.

Parameters
msgThe message to be logged

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