artdaq_mfextensions  v1_02_02
qt_mf_msg.cc
1 #include "messagefacility/Utilities/MessageFacilityMsg.h"
2 #include "messagefacility/Utilities/ELseverityLevel.h"
3 
4 #include "mfextensions/Binaries/qt_mf_msg.hh"
5 //#include "mfextensions/Extensions/MFExtensions.hh"
6 #include <iostream>
7 
8 size_t qt_mf_msg::sequence = 0;
9 
10 qt_mf_msg::qt_mf_msg(mf::MessageFacilityMsg const& msg)
11  : text_()
12  , shortText_()
13  , color_()
14  , sev_()
15  , host_(QString(msg.hostname().substr(0, msg.hostname().find_first_of('.')).c_str()))
16  , cat_(QString(msg.category().c_str()))
17  , app_(QString((msg.application() + " (" + std::to_string(msg.pid()) + ")").c_str()))
18  , time_(msg.timestamp())
19  , seq_(++sequence)
20 {
21  mf::ELseverityLevel severity(msg.severity());
22  int sevid = severity.getLevel();
23 
24  text_ = QString("<font color=");
25 
26  switch (sevid)
27  {
28 # if MESSAGEFACILITY_HEX_VERSION < 0x20002 // v2_00_02 is s50, pre v2_00_02 is s48
29  case mf::ELseverityLevel::ELsev_incidental:
30 # endif
31  case mf::ELseverityLevel::ELsev_success:
32  case mf::ELseverityLevel::ELsev_zeroSeverity:
33  case mf::ELseverityLevel::ELsev_unspecified:
34  sev_ = SDEBUG;
35  text_ += QString("#505050>");
36  color_.setRgb(80, 80, 80);
37  break;
38 
39  case mf::ELseverityLevel::ELsev_info:
40  sev_ = SINFO;
41  text_ += QString("#008000>");
42  color_.setRgb(0, 128, 0);
43  break;
44 
45  case mf::ELseverityLevel::ELsev_warning:
46 # if MESSAGEFACILITY_HEX_VERSION < 0x20002 // v2_00_02 is s50, pre v2_00_02 is s48
47  case mf::ELseverityLevel::ELsev_warning2:
48 # endif
49  sev_ = SWARNING;
50  text_ += QString("#E08000>");
51  color_.setRgb(224, 128, 0);
52  break;
53 
54  case mf::ELseverityLevel::ELsev_error:
55 # if MESSAGEFACILITY_HEX_VERSION < 0x20002 // v2_00_02 is s50, pre v2_00_02 is s48
56  case mf::ELseverityLevel::ELsev_error2:
57  case mf::ELseverityLevel::ELsev_next:
58  case mf::ELseverityLevel::ELsev_severe2:
59  case mf::ELseverityLevel::ELsev_abort:
60  case mf::ELseverityLevel::ELsev_fatal:
61 # endif
62  case mf::ELseverityLevel::ELsev_severe:
63  case mf::ELseverityLevel::ELsev_highestSeverity:
64  sev_ = SERROR;
65  text_ += QString("#FF0000>");
66  color_.setRgb(255, 0, 0);
67  break;
68 
69  default: break;
70  }
71 
72  shortText_ = QString(text_);
73  shortText_ += QString("<pre style=\"margin-top: 0; margin-bottom: 0;\">");
74  shortText_ += QString(msg.message().c_str()).trimmed().toHtmlEscaped();
75  shortText_ += QString("</pre></font>");
76 
77  //std::cout << "qt_mf_msg.cc:" << msg.message() << std::endl;
78  text_ += QString("<pre>")
79  + QString(severity.getName().c_str()).toHtmlEscaped() + " / "
80  + QString(msg.category().c_str()).toHtmlEscaped() + "<br>"
81  + QString(msg.timestr().c_str()).toHtmlEscaped() + "<br>"
82  + QString(msg.hostname().c_str()).toHtmlEscaped() + " ("
83  + QString(msg.hostaddr().c_str()).toHtmlEscaped() + ")<br>"
84 # if MESSAGEFACILITY_HEX_VERSION < 0x20002 // v2_00_02 is s50, pre v2_00_02 is s48
85  + QString(msg.process().c_str()).toHtmlEscaped()
86 #endif
87  + " ("
88  + QString::number(msg.pid()) + ")";
89 
90  if (msg.file().compare("--"))
91  text_ += QString(" / ") + QString(msg.file().c_str()).toHtmlEscaped()
92  + QString(":") + QString::number(msg.line());
93 
94  text_ += QString("<br>")
95  + QString(msg.application().c_str()).toHtmlEscaped() + " / "
96  + QString(msg.module().c_str()).toHtmlEscaped() + " / "
97  + QString(msg.context().c_str()).toHtmlEscaped() + "<br>"
98  + QString(msg.message().c_str()).toHtmlEscaped() // + "<br>"
99  + QString("</pre>");
100 
101  text_ += QString("</font>");
102 }
qt_mf_msg(mf::MessageFacilityMsg const &msg)
Construct a qt_mf_msg using the given MessageFacilityMsg
Definition: qt_mf_msg.cc:10