fire v0.19.0
Framework for sImulation and Reconstruction of Events
fire::logging Namespace Reference

Housing for logging infrastructure. More...

Typedefs

using logger = log::sources::severity_channel_logger_mt< level, std::string >
 Short names for boost::log. More...
 

Enumerations

enum  level {
  debug = 0 , info , warn , error ,
  fatal
}
 Different logging levels available to fire's log. More...
 

Functions

level convertLevel (int iLvl)
 Convert an integer to the severity level enum. More...
 
logger makeLogger (const std::string &name)
 Gets a logger for the user. More...
 
void open (const level termLevel, const level fileLevel, const std::string &fileName)
 Initialize the logging backend. More...
 
void close ()
 Close up the logging.
 
template<typename InputType , std::enable_if_t< std::is_convertible_v< InputType, level > > >
std::string print (InputType severity_level)
 Severity level to human readable name map. More...
 

Detailed Description

Housing for logging infrastructure.

This namespace holds the functions that allow fire to interact with boost's central logging framework in a helpful way.

Typedef Documentation

◆ logger

using fire::logging::logger = typedef log::sources::severity_channel_logger_mt<level, std::string>

Short names for boost::log.

short name for boost::log::sinks Define the type of logger we will be using in fire

We choose a logger that allows us to define a severity/logging level, has different "channels" for the log, and is multi-thread capable.

Enumeration Type Documentation

◆ level

Different logging levels available to fire's log.

Boost calls these "severity" levels becuase the higher numbers are assigned to "more sever" logging messages.

Enumerator
debug 

0

info 

1

warn 

2

error 

3

fatal 

5

Function Documentation

◆ convertLevel()

level fire::logging::convertLevel ( int  iLvl)

Convert an integer to the severity level enum.

Any integer below zero will be set to 0 (debug), and any integer above four will be set to 4 (fatal).

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

◆ makeLogger()

logger fire::logging::makeLogger ( const std::string name)

Gets a logger for the user.

Returns a logger type with some extra initialization procedures done. Should only be called ONCE during a run.

Note
Use the ENABLE_LOGGING macro in your class declaration instead of this function directly.
Parameters
namename of this logging channel (e.g. processor name)
Returns
logger with the input channel name

◆ open()

void fire::logging::open ( const level  termLevel,
const level  fileLevel,
const std::string fileName 
)

Initialize the logging backend.

This function setups up the terminal and file sinks. Sets their format and filtering level for this run.

Note
Will not setup printing log messages to file if fileName is empty string.
Parameters
termLevelminimum level to print to terminal (everything above it is also printed)
fileLevelminimum level to print to file log (everything above it is also printed)
fileNamename of file to print log to

◆ print()

template<typename InputType , std::enable_if_t< std::is_convertible_v< InputType, level > > >
std::string fire::logging::print ( InputType  severity_level)

Severity level to human readable name map.

Human readable names are the same width in characters

We could also add terminal color here if we wanted.

This function will only compile with values that can be implicity converted to a 'level'.

Note
Not compatible with funky type returned via Boost's extract method, so this function is currently not in use.