 |
Belle II Software
release-05-02-19
|
13 #include <framework/logging/LogConfig.h>
14 #include <framework/logging/LogMessage.h>
19 #include <unordered_map>
27 class LogConnectionBase;
219 std::unordered_map<LogMessage, int, LogMessage::TextHasher, LogMessage::TextHasher>
m_messageLog{100};
283 const int debugLevelLimit = config.getDebugLevel();
284 return logLevelLimit <= level && (level !=
LogConfig::c_Debug || debugLevelLimit >= debugLevel);
void addPackageLogConfig(const std::string &package, const LogConfig &logConfig)
Add the per package log configuration.
int getDebugLevel() const
Returns the configured debug messaging level.
static bool debugEnabled()
Is debug output enabled?
unsigned int m_suppressedMessages
The amount of messages we have suppressed so far just to get an indication we print this from time to...
static void enableDebug()
Enable debug output.
void resetLogConnections()
Removes all log connections.
void resetLogging()
Reset logging system to defaults: empty all log messages and reset connections to the default.
LogSystem & operator=(const LogSystem &)=delete
Disable/Hide the copy assignment operator.
void setMaxMessageRepetitions(unsigned repetitions)
Set maximum number of repetitions before silencing "identical" log messages.
std::unordered_map< LogMessage, int, LogMessage::TextHasher, LogMessage::TextHasher > m_messageLog
Count of previous log messages for the summary and to suppress repetitive messages.
std::map< std::string, LogConfig > m_packageLogConfigs
Stores the log configuration objects for packages.
bool sendMessage(LogMessage &&message)
Sends a log message using the log connection object.
unsigned getMaxMessageRepetitions() const
Get maximum number of repetitions before silencing "identical" log messages.
ELogLevel
Definition of the supported log levels.
void resetMessageCounter()
Resets the message counter and error log by setting all message counts to 0.
Abstract base class for the different types of log connections.
LogConfig & getPackageLogConfig(const std::string &package)
Get the log configuration for the package with the given name.
int m_messageCounter[LogConfig::c_Default]
Counts the number of messages sent per message level.
LogConfig m_logConfig
The global log system configuration.
LogConfig * getLogConfig()
Returns global log system configuration.
Abstract base class for different kinds of events.
Class for logging debug, info and error messages.
LogConfig::ELogLevel getCurrentLogLevel(const char *package=nullptr) const
Returns the current log level used by the logging system.
const LogConfig & getCurrentLogConfig(const char *package=nullptr) const
Returns the current LogConfig object used by the logging system.
void enableErrorSummary(bool on)
enable/disable error/warning summary after successful execution and B2FATAL.
void updateModule(const LogConfig *moduleLogConfig=nullptr, const std::string &moduleName="")
Sets the log configuration to the given module log configuration and sets the module name This method...
static bool s_debugEnabled
Global flag for fast checking if debug output is enabled.
unsigned int m_maxErrorRepetition
Maximum number to show the same message.
int getCurrentDebugLevel(const char *package=nullptr) const
Returns the current debug level used by the logging system.
std::string m_moduleName
The current module name.
bool deliverMessageToConnections(const LogMessage &msg)
Do nothing else than to send the message to all connected connections.
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
@ c_Message
Log message text.
std::vector< LogConnectionBase * > m_logConnections
Stores the pointers to the log connection objects.
LogSystem()
The constructor is hidden to avoid that someone creates an instance of this class.
static const unsigned int c_errorSummaryMaxLines
Error log will contain at most this many lines.
bool m_printErrorSummary
Wether to re-print errors-warnings encountered during execution at the end.
@ c_Debug
Debug: for code development.
void showText(LogConfig::ELogLevel level, const std::string &txt, int info=LogConfig::c_Message)
Send a custom message which looks like a log message but should not be counted as such.
ELogLevel getLogLevel() const
Returns the configured log level.
void addLogConnection(LogConnectionBase *logConnection)
Adds a log connection object which is used to the send the logging messages.
@ c_Default
Default: use globally configured log level.
~LogSystem()
The LogSystem destructor.
bool isLevelEnabled(LogConfig::ELogLevel level, int debugLevel=0, const char *package=nullptr) const
Returns true if the given log level is allowed by the log system (i.e.
void printErrorSummary()
Print error/warning summary at end of execution.
const LogConfig * m_moduleLogConfig
log config of current module
int getMessageCounter(LogConfig::ELogLevel logLevel) const
Returns the number of logging calls per log level.
void incMessageCounter(LogConfig::ELogLevel logLevel)
Increases the counter for the called message level by one.