EUDAQ
 All Classes Namespaces Files Functions Variables Pages
LogMessage.hh
1 #ifndef EUDAQ_INCLUDED_LogMessage
2 #define EUDAQ_INCLUDED_LogMessage
3 
4 #include <string>
5 #include <vector>
6 
7 #include "eudaq/Serializable.hh"
8 #include "eudaq/Serializer.hh"
9 #include "eudaq/Status.hh"
10 #include "eudaq/Time.hh"
11 #include "eudaq/Platform.hh"
12 
13 namespace eudaq {
14 
15  class DLLEXPORT LogMessage : public Status {
16  public:
17  LogMessage(const std::string &msg = "", Level level = LVL_EXTRA,
18  const Time &t = Time::Current());
20  virtual void Serialize(Serializer &) const;
21  virtual void Print(std::ostream &) const;
22  void Write(std::ostream &) const;
23  static LogMessage Read(std::istream &);
24  LogMessage &SetLocation(const std::string &file, unsigned line,
25  const std::string &func = "");
26  LogMessage &SetSender(const std::string &name);
27  std::string GetSender() const {
28  return m_sendertype +
29  (m_sendername == "" ? std::string("") : "." + m_sendername);
30  }
31  std::string GetSenderType() const { return m_sendertype; }
32  std::string GetSenderName() const { return m_sendername; }
33 
34  protected:
35  std::string m_file, m_func, m_sendertype, m_sendername;
36  unsigned m_line;
37  Time m_time, m_createtime;
38  };
39 
40  inline std::ostream &operator<<(std::ostream &os, const LogMessage &ev) {
41  ev.Print(os);
42  return os;
43  }
44 }
45 
46 #endif // EUDAQ_INCLUDED_LogMessage
Definition: Serializer.hh:156
Definition: Time.hh:32
Definition: Status.hh:15
Definition: LogMessage.hh:15
Definition: Serializer.hh:19