Belle II Software  release-05-02-19
LogConfig.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Andreas Moll, Thomas Kuhr *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 namespace Belle2 {
24  class LogConfig {
25  public:
26 
28  enum ELogLevel { c_Debug,
29  c_Info,
30  c_Result,
31  c_Warning,
33  c_Fatal,
34  c_Default
35  };
36 
38  enum ELogInfo { c_Level = 0x01,
39  c_Message = 0x02,
40  c_Module = 0x04,
41  c_Package = 0x08,
42  c_Function = 0x10,
43  c_File = 0x20,
44  c_Line = 0x40,
45  c_Timestamp = 0x80,
46  c_NoVariables = 0x100,
47  };
48 
49  static const int c_DefaultDebugLevel = 10;
57  LogConfig(ELogLevel logLevel = c_Default, int debugLevel = c_DefaultDebugLevel);
58 
65  static const char* logLevelToString(ELogLevel logLevelType);
66 
72  void setLogLevel(ELogLevel logLevel);
73 
79  ELogLevel getLogLevel() const {return m_logLevel; }
80 
86  void setDebugLevel(int debugLevel) {m_debugLevel = debugLevel; }
87 
93  int getDebugLevel() const {return m_debugLevel; }
94 
100  void setAbortLevel(ELogLevel abortLevel) {m_abortLevel = abortLevel; }
101 
107  ELogLevel getAbortLevel() const {return m_abortLevel; }
108 
115  void setLogInfo(ELogLevel logLevel, unsigned int logInfo) {m_logInfo[logLevel] = logInfo; }
116 
122  unsigned int getLogInfo(ELogLevel logLevel) const {return m_logInfo[logLevel]; }
123 
124 
125  private:
126 
128  int m_debugLevel;
131  unsigned int m_logInfo[c_Default];
132 
133  };
134 
136 } // end namespace Belle2
Belle2::LogConfig::getLogInfo
unsigned int getLogInfo(ELogLevel logLevel) const
Returns the configured log information for the given level.
Definition: LogConfig.h:130
Belle2::LogConfig::c_Result
@ c_Result
Result: for informational summary messages, e.g.
Definition: LogConfig.h:38
Belle2::LogConfig::getDebugLevel
int getDebugLevel() const
Returns the configured debug messaging level.
Definition: LogConfig.h:101
Belle2::LogConfig::c_Fatal
@ c_Fatal
Fatal: for situations were the program execution can not be continued.
Definition: LogConfig.h:41
Belle2::LogConfig::logLevelToString
static const char * logLevelToString(ELogLevel logLevelType)
Converts a log level type to a string.
Definition: LogConfig.cc:44
Belle2::LogConfig::setLogLevel
void setLogLevel(ELogLevel logLevel)
Configure the log level.
Definition: LogConfig.cc:27
Belle2::LogConfig::c_NoVariables
@ c_NoVariables
If set don't output any variables that are part of the message.
Definition: LogConfig.h:54
Belle2::LogConfig::m_debugLevel
int m_debugLevel
The debug messaging level.
Definition: LogConfig.h:136
Belle2::LogConfig::c_Info
@ c_Info
Info: for informational messages, e.g.
Definition: LogConfig.h:37
Belle2::LogConfig::c_File
@ c_File
Source file in which the message was emitted.
Definition: LogConfig.h:51
Belle2::LogConfig::setAbortLevel
void setAbortLevel(ELogLevel abortLevel)
Configure the abort level.
Definition: LogConfig.h:108
Belle2::LogConfig::m_logLevel
ELogLevel m_logLevel
The log messaging level.
Definition: LogConfig.h:135
Belle2::LogConfig::ELogLevel
ELogLevel
Definition of the supported log levels.
Definition: LogConfig.h:36
Belle2::LogConfig::c_Package
@ c_Package
Package in which the message was emitted.
Definition: LogConfig.h:49
Belle2::LogConfig::LogConfig
LogConfig(ELogLevel logLevel=c_Default, int debugLevel=c_DefaultDebugLevel)
The LogConfig constructor.
Definition: LogConfig.cc:19
Belle2::LogConfig::c_Line
@ c_Line
Line in source file in which the message was emitted.
Definition: LogConfig.h:52
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::LogConfig::m_logInfo
unsigned int m_logInfo[c_Default]
The kind of printed information per log level.
Definition: LogConfig.h:139
Belle2::LogConfig::c_Level
@ c_Level
Log level of the message.
Definition: LogConfig.h:46
Belle2::LogConfig::c_Error
@ c_Error
Error: for things that went wrong and have to be fixed.
Definition: LogConfig.h:40
Belle2::LogConfig::getAbortLevel
ELogLevel getAbortLevel() const
Returns the configured abort level.
Definition: LogConfig.h:115
Belle2::LogConfig::ELogInfo
ELogInfo
Definition of the supported log message information.
Definition: LogConfig.h:46
Belle2::LogConfig::c_Function
@ c_Function
Function in which the message was emitted.
Definition: LogConfig.h:50
Belle2::LogConfig::setLogInfo
void setLogInfo(ELogLevel logLevel, unsigned int logInfo)
Configure the printed log information for the given level.
Definition: LogConfig.h:123
Belle2::LogConfig::c_Message
@ c_Message
Log message text.
Definition: LogConfig.h:47
Belle2::LogConfig::c_Debug
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:36
Belle2::LogConfig::c_Warning
@ c_Warning
Warning: for potential problems that the user should pay attention to.
Definition: LogConfig.h:39
Belle2::LogConfig::getLogLevel
ELogLevel getLogLevel() const
Returns the configured log level.
Definition: LogConfig.h:87
Belle2::LogConfig::c_Default
@ c_Default
Default: use globally configured log level.
Definition: LogConfig.h:42
Belle2::LogConfig::m_abortLevel
ELogLevel m_abortLevel
The log level at which the execution should be stopped.
Definition: LogConfig.h:137
Belle2::LogConfig::c_DefaultDebugLevel
static const int c_DefaultDebugLevel
Default debug level.
Definition: LogConfig.h:57
Belle2::LogConfig::c_Timestamp
@ c_Timestamp
Time at which the message was emitted.
Definition: LogConfig.h:53
Belle2::LogConfig::setDebugLevel
void setDebugLevel(int debugLevel)
Configure the debug messaging level.
Definition: LogConfig.h:94
Belle2::LogConfig::c_Module
@ c_Module
Module in which the message was emitted.
Definition: LogConfig.h:48