Belle II Software  release-05-02-19
LogConfig.cc
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 #include <framework/logging/LogConfig.h>
12 #include <framework/logging/Logger.h>
13 
14 
15 using namespace std;
16 using namespace Belle2;
17 
18 
19 LogConfig::LogConfig(LogConfig::ELogLevel logLevel, int debugLevel) :
20  m_logLevel(logLevel),
21  m_debugLevel(debugLevel),
22  m_abortLevel(LogConfig::c_Fatal),
23  m_logInfo{0}
24 {}
25 
26 
28 {
29  if (logLevel == c_Fatal) {
30  // we want to show a warning that this is not possible but the log level
31  // might already be on error hiding the warning completely. We don't want
32  // to emit an error because this might abort processing. So force a warning
33  // message.
35  "Error messages cannot be switched off. The log level is set to ERROR instead of FATAL.",
36  PACKAGENAME(), FUNCTIONNAME(), __FILE__, __LINE__, 0));
37  logLevel = c_Error;
38  }
39  if (logLevel == c_Debug) Belle2::LogSystem::enableDebug();
40  m_logLevel = logLevel;
41 }
42 
43 
45 {
46  static const char* logLevelString[] = {"DEBUG", "INFO", "RESULT", "WARNING", "ERROR", "FATAL", "default"};
47  return logLevelString[logLevelType];
48 }
Belle2::LogSystem::enableDebug
static void enableDebug()
Enable debug output.
Definition: LogSystem.h:206
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::LogSystem::sendMessage
bool sendMessage(LogMessage &&message)
Sends a log message using the log connection object.
Definition: LogSystem.cc:71
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
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::LogConfig::c_Error
@ c_Error
Error: for things that went wrong and have to be fixed.
Definition: LogConfig.h:40
Belle2::LogSystem::Instance
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:33
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
The LogConfig class.
Definition: LogConfig.h:32
Belle2::LogMessage
The LogMessage class.
Definition: LogMessage.h:39