Belle II Software development
LogMethod.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/LogMethod.h>
10#include <framework/logging/LogConfig.h>
11#include <framework/logging/LogMessage.h>
12#include <framework/logging/LogSystem.h>
13
14#include <utility>
15
16using namespace std;
17using namespace Belle2;
18
19LogMethod::LogMethod(const char* package, string function, string file, unsigned int line): m_package(package),
20 m_function(std::move(function)), m_file(std::move(file)), m_line(line)
21{
22 //Send message for entering the method
23 if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Info)) {
24 string messageText = "--> Entering method '" + m_function + "'";
26 }
27}
28
30{
31 //Check for uncaught exceptions
32 string uncaughtExc;
33 if (std::uncaught_exceptions() > 0) uncaughtExc = "(" + std::to_string(std::uncaught_exceptions()) +
34 " uncaught exceptions pending)";
35
36 //Send message for leaving the method
37 if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Info)) {
38 string messageText = "<-- Leaving method '" + m_function + "' " + uncaughtExc;
40 }
41}
@ c_Info
Info: for informational messages, e.g.
Definition: LogConfig.h:27
The LogMessage class.
Definition: LogMessage.h:29
~LogMethod()
The LogMethod destructor.
Definition: LogMethod.cc:29
unsigned int m_line
The line number in the source code where the message was sent from.
Definition: LogMethod.h:56
const char * m_package
The package name where the message was sent from.
Definition: LogMethod.h:53
LogMethod(const char *package, std::string function, std::string file, unsigned int line)
The LogMethod constructor.
Definition: LogMethod.cc:19
std::string m_file
The file name where the message was sent from.
Definition: LogMethod.h:55
std::string m_function
The function name where the message was sent from.
Definition: LogMethod.h:54
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
Abstract base class for different kinds of events.
STL namespace.