Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
jlog.cc
Go to the documentation of this file.
1#include "log.hh"
2
6
7/**
8 * \author cpellegrino
9 */
10
11using namespace JPP;
12
13class MLSing
14{
15 MLSing() {}
17
18 public:
19
20 static MLSing& get()
21 {
22 static MLSing sing;
23
24 return sing;
25 }
26
27 void init(JMessageLoggerThreadSafe const& second)
28 {
29 m_mlts = second;
30 }
31
33 {
34 return m_mlts;
35 }
36};
37
39{
40 MLSing::get().init(second);
41}
42
43void setLogLevel(int level)
44{
45 // This shall be protected from race conditions with a mutex to avoid UB.
46 // But this very UB won't really produce any problem, hopefully.
47 MLSing::get().logger().setLevel(level);
48}
49
51{
52 if (m_level == cError) {
53 JLOGGER::JErrorStream(MLSing::get().logger()) << m_stream.str();
54 } else if (m_level == cWarning) {
55 JLOGGER::JWarningStream(MLSing::get().logger()) << m_stream.str();
56 } else if (m_level == cNotice) {
57 JLOGGER::JNoticeStream (MLSing::get().logger()) << m_stream.str();
58 } else if (m_level == cStatus) {
59 JLOGGER::JStatusStream (MLSing::get().logger()) << m_stream.str();
60 } else if (m_level == cDebug) {
61 JLOGGER::JDebugStream (MLSing::get().logger()) << m_stream.str();
62 }
63}
General purpose message reporting.
Message reporting compatible with STL output stream operations.
Thread-safe message logger.
void setLevel(const int __level)
Set debug level.
std::ostringstream m_stream
Definition log.hh:19
~Logger()
Logger without Jpp.
Definition jlog.cc:50
LogLevel m_level
Definition log.hh:21
Definition jlog.cc:14
MLSing()
Definition jlog.cc:15
static MLSing & get()
Definition jlog.cc:20
JMessageLoggerThreadSafe & logger()
Definition jlog.cc:32
void init(JMessageLoggerThreadSafe const &second)
Definition jlog.cc:27
JMessageLoggerThreadSafe m_mlts
Definition jlog.cc:16
void setLogLevel(int level)
Definition jlog.cc:43
void initLogger(JMessageLoggerThreadSafe const &second)
Definition jlog.cc:38
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
@ cStatus
Definition log.hh:15
@ cWarning
Definition log.hh:15
@ cError
Definition log.hh:15
@ cDebug
Definition log.hh:15
@ cNotice
Definition log.hh:15
Level specific message streamers.