Belle II Software  release-05-02-19
LogMethod.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 *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <framework/logging/LogMethod.h>
12 #include <framework/logging/LogConfig.h>
13 #include <framework/logging/LogMessage.h>
14 #include <framework/logging/LogSystem.h>
15 
16 #include <utility>
17 
18 using namespace std;
19 using namespace Belle2;
20 
21 LogMethod::LogMethod(const char* package, string function, string file, unsigned int line): m_package(package),
22  m_function(std::move(function)), m_file(std::move(file)), m_line(line)
23 {
24  //Send message for entering the method
25  if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Info)) {
26  string messageText = "--> Entering method '" + m_function + "'";
28  }
29 }
30 
32 {
33  //Check for uncaught exceptions
34  string uncaughtExc;
35  if (std::uncaught_exceptions() > 0) uncaughtExc = "(" + std::to_string(std::uncaught_exceptions()) +
36  " uncaught exceptions pending)";
37 
38  //Send message for leaving the method
39  if (LogSystem::Instance().isLevelEnabled(LogConfig::c_Info)) {
40  string messageText = "<-- Leaving method '" + m_function + "' " + uncaughtExc;
42  }
43 }
Belle2::LogMethod::m_package
const char * m_package
The package name where the message was sent from.
Definition: LogMethod.h:63
Belle2::LogMethod::~LogMethod
~LogMethod()
The LogMethod destructor.
Definition: LogMethod.cc:31
Belle2::LogSystem::sendMessage
bool sendMessage(LogMessage &&message)
Sends a log message using the log connection object.
Definition: LogSystem.cc:71
Belle2::LogConfig::c_Info
@ c_Info
Info: for informational messages, e.g.
Definition: LogConfig.h:37
Belle2::LogMethod::m_file
std::string m_file
The file name where the message was sent from.
Definition: LogMethod.h:65
Belle2::LogMethod::m_line
unsigned int m_line
The line number in the source code where the message was sent from.
Definition: LogMethod.h:66
Belle2::LogMethod::m_function
std::string m_function
The function name where the message was sent from.
Definition: LogMethod.h:64
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::LogSystem::Instance
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:33
Belle2::LogMessage
The LogMessage class.
Definition: LogMessage.h:39