Jpp
jlog.cc
Go to the documentation of this file.
1 #include "log.hh"
2 
6 
7 /**
8  * \author cpellegrino
9  */
10 
11 using namespace JPP;
12 
13 class MLSing
14 {
15  MLSing() {}
16  JMessageLoggerThreadSafe m_mlts;
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 
32  JMessageLoggerThreadSafe& logger()
33  {
34  return m_mlts;
35  }
36 };
37 
38 void initLogger(JMessageLoggerThreadSafe const& second)
39 {
40  MLSing::get().init(second);
41 }
42 
43 void 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 }
JLOGGER::JDebugStream
Level specific message streamers.
Definition: JMessageStream.hh:113
JLOGGER::JNoticeStream
Definition: JMessageStream.hh:116
setLogLevel
void setLogLevel(int level)
Definition: jlog.cc:43
MLSing::init
void init(JMessageLoggerThreadSafe const &second)
Definition: jlog.cc:27
Log::Logger::~Logger
~Logger()
Logger without Jpp.
Definition: jlog.cc:50
log.hh
JMessageStream.hh
JLOGGER::JErrorStream
Definition: JMessageStream.hh:115
MLSing::m_mlts
JMessageLoggerThreadSafe m_mlts
Definition: jlog.cc:16
MLSing::logger
JMessageLoggerThreadSafe & logger()
Definition: jlog.cc:32
MLSing
Definition: jlog.cc:13
JControlHostLogger.hh
initLogger
void initLogger(JMessageLoggerThreadSafe const &second)
Definition: jlog.cc:38
JLOGGER::JMessageLogger::setLevel
void setLevel(const int __level)
Set debug level.
Definition: JMessageLogger.hh:128
MLSing::MLSing
MLSing()
Definition: jlog.cc:15
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
Log::cWarning
Definition: log.hh:15
Log::cDebug
Definition: log.hh:15
Log::cNotice
Definition: log.hh:15
JLOGGER::JWarningStream
Definition: JMessageStream.hh:114
JLOGGER::JStatusStream
Definition: JMessageStream.hh:117
MLSing::get
static MLSing & get()
Definition: jlog.cc:20
Log::cStatus
Definition: log.hh:15
Log::cError
Definition: log.hh:15
JMessageLogger.hh