artdaq_mfextensions  v1_05_00
qt_mf_msg.hh
1 #ifndef MESSAGEFACILITY_EXTENSIONS_QT_MF_MSG_H
2 #define MESSAGEFACILITY_EXTENSIONS_QT_MF_MSG_H
3 
4 // Wrapped mf message type to be used by msgviewer for
5 // the purpose of fast processing
6 
7 #include <QtCore/QString>
8 #include <QtGui/QColor>
9 
10 #include <list>
11 #include <map>
12 #include <string>
13 #include <vector>
14 #include <memory>
15 
16 #include <sys/time.h>
17 #include "messagefacility/Utilities/ELseverityLevel.h"
18 
19 namespace mf {
20 class ErrorObj;
21 }
22 
26 enum sev_code_t
27 {
28  SDEBUG,
29  SINFO,
30  SWARNING,
31  SERROR
32 };
33 
37 class qt_mf_msg
38 {
39 public:
48  qt_mf_msg(const std::string& hostname, const std::string& category, const std::string& application, pid_t pid, timeval time);
49 
51  qt_mf_msg() {}
53  qt_mf_msg(const qt_mf_msg&) = default;
54  qt_mf_msg(qt_mf_msg&&) = default;
55  qt_mf_msg& operator=(qt_mf_msg const&) = default;
56  qt_mf_msg& operator=(qt_mf_msg&&) = default;
57 
58  virtual ~qt_mf_msg() = default;
59 
60  // get method
66  QString const& text(bool mode) const { return mode ? shortText_ : text_; }
71  QColor const& color() const { return color_; }
76  sev_code_t sev() const { return sev_; }
81  QString const& host() const { return host_; }
86  QString const& cat() const { return cat_; }
91  QString const& app() const { return app_; }
96  timeval time() const { return time_; }
101  size_t seq() const { return seq_; }
102 
107  void setSeverity(mf::ELseverityLevel sev);
112  void setSeverityLevel(sev_code_t sev) { sev_ = sev; }
119  void setMessage(const std::string& prefix, int iteration, const std::string& msg);
124  void setHostAddr(std::string const& hostaddr) { hostaddr_ = QString(hostaddr.c_str()).toHtmlEscaped(); }
129  void setFileName(std::string const& file) { file_ = QString(file.c_str()).toHtmlEscaped(); }
134  void setLineNumber(std::string const& line) { line_ = QString(line.c_str()).toHtmlEscaped(); }
139  void setModule(std::string const& module) { module_ = QString(module.c_str()).toHtmlEscaped(); }
144  void setEventID(std::string const& eventID) { eventID_ = QString(eventID.c_str()).toHtmlEscaped(); }
145 
149  void updateText();
150 
151 private:
152 
153  QString text_;
154  QString shortText_;
155  QColor color_;
156  sev_code_t sev_;
157  QString host_;
158  QString cat_;
159  QString app_;
160  timeval time_;
161  size_t seq_;
162  static size_t sequence;
163 
164  QString msg_;
165  QString application_;
166  QString pid_;
167  QString hostaddr_;
168  QString file_;
169  QString line_;
170  QString module_;
171  QString eventID_;
172  QString sourceType_;
173  int sourceSequence_;
174 };
175 
179 typedef std::shared_ptr<qt_mf_msg> msg_ptr_t;
180 
184 typedef std::list<msg_ptr_t> msgs_t;
185 
189 typedef std::map<QString, msgs_t> msgs_map_t;
190 
191 #endif
QString const & app() const
Get the application of the message
Definition: qt_mf_msg.hh:91
void updateText()
Parse fields and create HTML string representing message
Definition: qt_mf_msg.cc:62
timeval time() const
Get the message timestamp
Definition: qt_mf_msg.hh:96
size_t seq() const
Get the sequence number of the message
Definition: qt_mf_msg.hh:101
Qt wrapper around MessageFacility message
Definition: qt_mf_msg.hh:37
void setModule(std::string const &module)
Set the module name
Definition: qt_mf_msg.hh:139
sev_code_t sev() const
Get the severity of the message
Definition: qt_mf_msg.hh:76
void setSeverityLevel(sev_code_t sev)
Set the severity code of the message (Viewer levels)
Definition: qt_mf_msg.hh:112
QString const & host() const
Get the host from which the message came
Definition: qt_mf_msg.hh:81
void setMessage(const std::string &prefix, int iteration, const std::string &msg)
Set the message
Definition: qt_mf_msg.cc:55
void setEventID(std::string const &eventID)
Set the Event ID of the message
Definition: qt_mf_msg.hh:144
void setHostAddr(std::string const &hostaddr)
Set the hostaddr field
Definition: qt_mf_msg.hh:124
void setFileName(std::string const &file)
Set the file name field
Definition: qt_mf_msg.hh:129
qt_mf_msg()
Default message constructor.
Definition: qt_mf_msg.hh:51
void setSeverity(mf::ELseverityLevel sev)
Set the Severity of the message (MF levels)
Definition: qt_mf_msg.cc:24
void setLineNumber(std::string const &line)
Set the line number field
Definition: qt_mf_msg.hh:134
QString const & text(bool mode) const
Get the text of the message
Definition: qt_mf_msg.hh:66
QString const & cat() const
Get the category of the message
Definition: qt_mf_msg.hh:86
QColor const & color() const
Get the severity-based color of the message
Definition: qt_mf_msg.hh:71