Belle II Software development
LogConfig.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <framework/logging/LogConfig.h>
10#include <framework/logging/Logger.h>
11
12
13using namespace std;
14using namespace Belle2;
15
16
17LogConfig::LogConfig(LogConfig::ELogLevel logLevel, int debugLevel) :
18 m_logLevel(logLevel),
19 m_debugLevel(debugLevel),
20 m_abortLevel(LogConfig::c_Fatal),
21 m_logInfo{0}
22{}
23
24
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}
40
41
43{
44 static const char* logLevelString[] = {"DEBUG", "INFO", "RESULT", "WARNING", "ERROR", "FATAL", "default"};
45 return logLevelString[logLevelType];
46}
47
48
50{
51 static const char* logRealmString[] = {"none", "online", "production"};
52 return logRealmString[realm];
53}
The LogConfig class.
Definition: LogConfig.h:22
LogConfig(ELogLevel logLevel=c_Default, int debugLevel=c_DefaultDebugLevel)
The LogConfig constructor.
Definition: LogConfig.cc:17
ELogLevel m_logLevel
The log messaging level.
Definition: LogConfig.h:139
static const char * logRealmToString(ELogRealm realm)
Converts a log realm type to a string.
Definition: LogConfig.cc:49
ELogLevel
Definition of the supported log levels.
Definition: LogConfig.h:26
@ c_Error
Error: for things that went wrong and have to be fixed.
Definition: LogConfig.h:30
@ 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
ELogRealm
Definition of the supported execution realms.
Definition: LogConfig.h:48
void setLogLevel(ELogLevel logLevel)
Configure the log level.
Definition: LogConfig.cc:25
static const char * logLevelToString(ELogLevel logLevelType)
Converts a log level type to a string.
Definition: LogConfig.cc:42
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
Abstract base class for different kinds of events.
STL namespace.