 |
Belle II Software
release-05-02-19
|
11 #include <framework/logging/LogMessage.h>
13 #include <framework/utilities/Utils.h>
14 #include <framework/gearbox/Unit.h>
15 #include <framework/pcore/ProcHandler.h>
17 #include <boost/property_tree/json_parser.hpp>
25 std::string
function, std::string file,
unsigned int line,
int debugLevel) :
29 m_package(package ? package :
""),
30 m_function(std::move(function)),
31 m_file(std::move(file)),
33 m_debugLevel(debugLevel),
39 std::string
function, std::string file,
unsigned int line,
int debugLevel) :
41 m_message(std::move(messageStream)),
43 m_package(package ? package :
""),
44 m_function(std::move(function)),
45 m_file(std::move(file)),
47 m_debugLevel(debugLevel),
56 (
m_line == message.m_line) &&
61 (
m_file == message.m_file));
66 using namespace boost::property_tree::json_parser;
67 std::stringstream buffer;
79 buffer <<
",\"variables\":{";
81 for (
const auto& v : vars) {
82 if (!first) buffer <<
",";
83 buffer <<
'"' << create_escapes(v.getName()) <<
"\":\"" << create_escapes(v.getValue()) <<
'"';
90 buffer << R
"(,"module":")" << create_escapes(m_module) << '"';
92 buffer << R
"(,"package":")" << create_escapes(m_package) << '"';
94 buffer << R
"(,"function":")" << create_escapes(m_function) << '"';
96 buffer << R
"(,"file":")" << create_escapes(m_file) << '"';
98 buffer <<
",\"line\":" <<
m_line;
100 buffer <<
",\"timestamp\":" << std::fixed << std::setprecision(3) << time;
115 const auto flags = out.flags();
116 const int oldprecision = out.precision(3);
118 out.precision(oldprecision);
169 return logMessage.
print(out);
static const double s
[second]
std::string getMessage() const
Return the constant message part without the variables.
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
Specialized implementation of an ostream-like class where the << operator can be used to insert value...
int m_debugLevel
The debug level for messages with level=c_Debug.
static const char * logLevelToString(ELogLevel logLevelType)
Converts a log level type to a string.
LogVariableStream m_message
The message stream which should be sent.
@ c_NoVariables
If set don't output any variables that are part of the message.
bool operator==(const LogMessage &message) const
Compares two messages.
std::string m_package
The package name where the message was sent from.
@ c_File
Source file in which the message was emitted.
std::string str(bool showVariables=true) const
Return the content of the stream as string.
ELogLevel
Definition of the supported log levels.
LogMessage(LogConfig::ELogLevel logLevel, const std::string &message, const char *package, std::string function, std::string file, unsigned int line, int debugLevel=0)
The LogMessage constructor.
@ c_Package
Package in which the message was emitted.
@ c_Line
Line in source file in which the message was emitted.
Abstract base class for different kinds of events.
unsigned int m_logInfo
kind of information to show (ORed combination of LogConfig::ELogInfo flags).
@ c_Level
Log level of the message.
std::string m_function
The function name where the message was sent from.
const std::vector< LogVar > & getVariables() const
Return the list of all defined variables.
LogConfig::ELogLevel m_logLevel
The log level of the message.
std::string m_module
The module name where the message was sent from.
static int EvtProcID()
Return ID of the current process.
std::string toJSON(bool complete) const
Return a json string for the log message.
@ c_Function
Function in which the message was emitted.
double getClock()
Return current value of the real-time clock.
@ c_Message
Log message text.
@ c_Debug
Debug: for code development.
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.
@ c_Timestamp
Time at which the message was emitted.
std::ostream & print(std::ostream &out) const
Generate output stream.
@ c_Module
Module in which the message was emitted.