Belle II Software light-2406-ragdoll
LogConfig Class Reference

The LogConfig class. More...

#include <LogConfig.h>

Public Types

enum  ELogLevel {
  c_Debug ,
  c_Info ,
  c_Result ,
  c_Warning ,
  c_Error ,
  c_Fatal ,
  c_Default
}
 Definition of the supported log levels. More...
 
enum  ELogInfo {
  c_Level = 0x01 ,
  c_Message = 0x02 ,
  c_Module = 0x04 ,
  c_Package = 0x08 ,
  c_Function = 0x10 ,
  c_File = 0x20 ,
  c_Line = 0x40 ,
  c_Timestamp = 0x80 ,
  c_NoVariables = 0x100
}
 Definition of the supported log message information. More...
 
enum  ELogRealm {
  c_None ,
  c_Online ,
  c_Production
}
 Definition of the supported execution realms. More...
 

Public Member Functions

 LogConfig (ELogLevel logLevel=c_Default, int debugLevel=c_DefaultDebugLevel)
 The LogConfig constructor.
 
void setLogLevel (ELogLevel logLevel)
 Configure the log level.
 
ELogLevel getLogLevel () const
 Returns the configured log level.
 
void setDebugLevel (int debugLevel)
 Configure the debug messaging level.
 
int getDebugLevel () const
 Returns the configured debug messaging level.
 
void setAbortLevel (ELogLevel abortLevel)
 Configure the abort level.
 
ELogLevel getAbortLevel () const
 Returns the configured abort level.
 
void setLogInfo (ELogLevel logLevel, unsigned int logInfo)
 Configure the printed log information for the given level.
 
unsigned int getLogInfo (ELogLevel logLevel) const
 Returns the configured log information for the given level.
 

Static Public Member Functions

static const char * logLevelToString (ELogLevel logLevelType)
 Converts a log level type to a string.
 
static const char * logRealmToString (ELogRealm realm)
 Converts a log realm type to a string.
 

Static Public Attributes

static const int c_DefaultDebugLevel = 10
 Default debug level.
 

Private Attributes

ELogLevel m_logLevel
 The log messaging level.
 
int m_debugLevel
 The debug messaging level.
 
ELogLevel m_abortLevel
 The log level at which the execution should be stopped.
 
unsigned int m_logInfo [c_Default]
 The kind of printed information per log level.
 

Detailed Description

The LogConfig class.

This class provides configuration settings for the logging system.

Definition at line 22 of file LogConfig.h.

Member Enumeration Documentation

◆ ELogInfo

enum ELogInfo

Definition of the supported log message information.

Enumerator
c_Level 

Log level of the message.


c_Message 

Log message text.


c_Module 

Module in which the message was emitted.

c_Package 

Package in which the message was emitted.

c_Function 

Function in which the message was emitted.

c_File 

Source file in which the message was emitted.

c_Line 

Line in source file in which the message was emitted.

c_Timestamp 

Time at which the message was emitted.

c_NoVariables 

If set don't output any variables that are part of the message.

Definition at line 36 of file LogConfig.h.

36 { c_Level = 0x01,
37 c_Message = 0x02,
38 c_Module = 0x04,
39 c_Package = 0x08,
40 c_Function = 0x10,
41 c_File = 0x20,
42 c_Line = 0x40,
43 c_Timestamp = 0x80,
44 c_NoVariables = 0x100,
45 };
@ c_Module
Module in which the message was emitted.
Definition: LogConfig.h:38
@ c_File
Source file in which the message was emitted.
Definition: LogConfig.h:41
@ c_Function
Function in which the message was emitted.
Definition: LogConfig.h:40
@ c_Line
Line in source file in which the message was emitted.
Definition: LogConfig.h:42
@ c_Level
Log level of the message.
Definition: LogConfig.h:36
@ c_Package
Package in which the message was emitted.
Definition: LogConfig.h:39
@ c_Message
Log message text.
Definition: LogConfig.h:37
@ c_NoVariables
If set don't output any variables that are part of the message.
Definition: LogConfig.h:44
@ c_Timestamp
Time at which the message was emitted.
Definition: LogConfig.h:43

◆ ELogLevel

enum ELogLevel

Definition of the supported log levels.

In ascending order !

Enumerator
c_Debug 

Debug: for code development.


c_Info 

Info: for informational messages, e.g.

about opened files, processed events, etc.

c_Result 

Result: for informational summary messages, e.g.

about number of selected events

c_Warning 

Warning: for potential problems that the user should pay attention to.

c_Error 

Error: for things that went wrong and have to be fixed.

c_Fatal 

Fatal: for situations were the program execution can not be continued.

c_Default 

Default: use globally configured log level.


Definition at line 26 of file LogConfig.h.

26 { c_Debug,
27 c_Info,
28 c_Result,
29 c_Warning,
30 c_Error,
31 c_Fatal,
33 };
@ c_Error
Error: for things that went wrong and have to be fixed.
Definition: LogConfig.h:30
@ c_Info
Info: for informational messages, e.g.
Definition: LogConfig.h:27
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:26
@ c_Fatal
Fatal: for situations were the program execution can not be continued.
Definition: LogConfig.h:31
@ c_Warning
Warning: for potential problems that the user should pay attention to.
Definition: LogConfig.h:29
@ c_Result
Result: for informational summary messages, e.g.
Definition: LogConfig.h:28
@ c_Default
Default: use globally configured log level.
Definition: LogConfig.h:32

◆ ELogRealm

enum ELogRealm

Definition of the supported execution realms.

Enumerator
c_None 

No specific realm.

c_Online 

Online data taking.

c_Production 

Data production jobs.

Definition at line 48 of file LogConfig.h.

48 { c_None,
49 c_Online,
51 };
@ c_None
No specific realm.
Definition: LogConfig.h:48
@ c_Online
Online data taking.
Definition: LogConfig.h:49
@ c_Production
Data production jobs.
Definition: LogConfig.h:50

Constructor & Destructor Documentation

◆ LogConfig()

LogConfig ( LogConfig::ELogLevel  logLevel = c_Default,
int  debugLevel = c_DefaultDebugLevel 
)

The LogConfig constructor.

Parameters
logLevelThe log level.
debugLevelThe debug level.

Definition at line 17 of file LogConfig.cc.

17 :
18 m_logLevel(logLevel),
19 m_debugLevel(debugLevel),
21 m_logInfo{0}
22{}
ELogLevel m_abortLevel
The log level at which the execution should be stopped.
Definition: LogConfig.h:141
int m_debugLevel
The debug messaging level.
Definition: LogConfig.h:140
unsigned int m_logInfo[c_Default]
The kind of printed information per log level.
Definition: LogConfig.h:143
ELogLevel m_logLevel
The log messaging level.
Definition: LogConfig.h:139

Member Function Documentation

◆ getAbortLevel()

ELogLevel getAbortLevel ( ) const
inline

Returns the configured abort level.

Returns
Returns the configured abort level.

Definition at line 119 of file LogConfig.h.

119{return m_abortLevel; }

◆ getDebugLevel()

int getDebugLevel ( ) const
inline

Returns the configured debug messaging level.

Returns
Returns the configured debug messaging level.

Definition at line 105 of file LogConfig.h.

105{return m_debugLevel; }

◆ getLogInfo()

unsigned int getLogInfo ( ELogLevel  logLevel) const
inline

Returns the configured log information for the given level.

Returns
Returns the configured log information.

Definition at line 134 of file LogConfig.h.

134{return m_logInfo[logLevel]; }

◆ getLogLevel()

ELogLevel getLogLevel ( ) const
inline

Returns the configured log level.

Returns
Returns the configured log level.

Definition at line 91 of file LogConfig.h.

91{return m_logLevel; }

◆ logLevelToString()

const char * logLevelToString ( LogConfig::ELogLevel  logLevelType)
static

Converts a log level type to a string.

Parameters
logLevelTypeThe type of the log level.
Returns
The string representation of the log level type.

Definition at line 42 of file LogConfig.cc.

43{
44 static const char* logLevelString[] = {"DEBUG", "INFO", "RESULT", "WARNING", "ERROR", "FATAL", "default"};
45 return logLevelString[logLevelType];
46}

◆ logRealmToString()

const char * logRealmToString ( LogConfig::ELogRealm  realm)
static

Converts a log realm type to a string.

Parameters
realmThe log realm.
Returns
The string representation of the log realm.

Definition at line 49 of file LogConfig.cc.

50{
51 static const char* logRealmString[] = {"none", "online", "production"};
52 return logRealmString[realm];
53}

◆ setAbortLevel()

void setAbortLevel ( ELogLevel  abortLevel)
inline

Configure the abort level.

Parameters
abortLevelThe abort log level.

Definition at line 112 of file LogConfig.h.

112{m_abortLevel = abortLevel; }

◆ setDebugLevel()

void setDebugLevel ( int  debugLevel)
inline

Configure the debug messaging level.

Parameters
debugLevelThe debug level.

Definition at line 98 of file LogConfig.h.

98{m_debugLevel = debugLevel; }

◆ setLogInfo()

void setLogInfo ( ELogLevel  logLevel,
unsigned int  logInfo 
)
inline

Configure the printed log information for the given level.

Parameters
logLevelThe log level.
logInfoThe log information that should be printed.

Definition at line 127 of file LogConfig.h.

127{m_logInfo[logLevel] = logInfo; }

◆ setLogLevel()

void setLogLevel ( ELogLevel  logLevel)

Configure the log level.

Parameters
logLevelThe log level.

Definition at line 25 of file LogConfig.cc.

26{
27 if (logLevel == c_Fatal) {
28 // we want to show a warning that this is not possible but the log level
29 // might already be on error hiding the warning completely. We don't want
30 // to emit an error because this might abort processing. So force a warning
31 // message.
33 "Error messages cannot be switched off. The log level is set to ERROR instead of FATAL.",
34 PACKAGENAME(), FUNCTIONNAME(), __FILE__, __LINE__, 0));
35 logLevel = c_Error;
36 }
37 if (logLevel == c_Debug) Belle2::LogSystem::enableDebug();
38 m_logLevel = logLevel;
39}
The LogMessage class.
Definition: LogMessage.h:29
bool sendMessage(LogMessage &&message)
Sends a log message using the log connection object.
Definition: LogSystem.cc:69
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:31
static void enableDebug()
Enable debug output.
Definition: LogSystem.h:196

Member Data Documentation

◆ c_DefaultDebugLevel

const int c_DefaultDebugLevel = 10
static

Default debug level.

Definition at line 53 of file LogConfig.h.

◆ m_abortLevel

ELogLevel m_abortLevel
private

The log level at which the execution should be stopped.

Definition at line 141 of file LogConfig.h.

◆ m_debugLevel

int m_debugLevel
private

The debug messaging level.

Definition at line 140 of file LogConfig.h.

◆ m_logInfo

unsigned int m_logInfo[c_Default]
private

The kind of printed information per log level.

(ORed combination of LogConfig::ELogInfo flags).

Definition at line 143 of file LogConfig.h.

◆ m_logLevel

ELogLevel m_logLevel
private

The log messaging level.

Defined as int for the parameter handling.

Definition at line 139 of file LogConfig.h.


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