Belle II Software light-2406-ragdoll
LogMethod Class Reference

The LogMethod class. More...

#include <LogMethod.h>

Collaboration diagram for LogMethod:

Public Member Functions

 LogMethod (const char *package, std::string function, std::string file, unsigned int line)
 The LogMethod constructor.
 
 ~LogMethod ()
 The LogMethod destructor.
 

Private Attributes

const char * m_package
 The package name where the message was sent from.
 
std::string m_function
 The function name where the message was sent from.
 
std::string m_file
 The file name where the message was sent from.
 
unsigned int m_line
 The line number in the source code where the message was sent from.
 

Detailed Description

The LogMethod class.

This class allows the logging of the entering and leaving point of a method. Therefore an object of this class is created on the stack, which logs a message at the moment it is created and destroyed. In addition, it logs a message if there are any uncaught exceptions pending at the time the object is destroyed on the stack. This allows to identify methods which were terminated due to a thrown exception.

Definition at line 31 of file LogMethod.h.

Constructor & Destructor Documentation

◆ LogMethod()

LogMethod ( const char *  package,
std::string  function,
std::string  file,
unsigned int  line 
)

The LogMethod constructor.

Parameters
packageThe package name where the message was sent from.
functionThe function name where the message was sent from.
fileThe file name where the message was sent from.
lineThe line number in the source code where the message was sent from.

Definition at line 19 of file LogMethod.cc.

19 : 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}
@ c_Info
Info: for informational messages, e.g.
Definition: LogConfig.h:27
The LogMessage class.
Definition: LogMessage.h: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
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

◆ ~LogMethod()

~LogMethod ( )

The LogMethod destructor.

Definition at line 29 of file LogMethod.cc.

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}

Member Data Documentation

◆ m_file

std::string m_file
private

The file name where the message was sent from.

Definition at line 55 of file LogMethod.h.

◆ m_function

std::string m_function
private

The function name where the message was sent from.

Definition at line 54 of file LogMethod.h.

◆ m_line

unsigned int m_line
private

The line number in the source code where the message was sent from.

Definition at line 56 of file LogMethod.h.

◆ m_package

const char* m_package
private

The package name where the message was sent from.

Definition at line 53 of file LogMethod.h.


The documentation for this class was generated from the following files: