1 #include "messagefacility/Utilities/ELseverityLevel.h"
3 #include "mfextensions/Receivers/qt_mf_msg.hh"
4 #include "messagefacility/MessageService/ELdestination.h"
8 size_t qt_mf_msg::sequence = 0;
10 qt_mf_msg::qt_mf_msg(std::string hostname, std::string category, std::string application, pid_t pid, timeval time)
15 , host_(QString(hostname.c_str()))
16 , cat_(QString(category.c_str()))
17 , app_(QString((application +
" (" + std::to_string(pid) +
")").c_str()))
21 , application_(QString(application.c_str()).toHtmlEscaped())
22 , pid_(QString::number(pid))
26 void qt_mf_msg::setSeverity(mf::ELseverityLevel sev)
28 int sevid = sev.getLevel();
32 # if MESSAGEFACILITY_HEX_VERSION < 0x20002 // v2_00_02 is s50, pre v2_00_02 is s48
33 case mf::ELseverityLevel::ELsev_incidental:
35 case mf::ELseverityLevel::ELsev_success:
36 case mf::ELseverityLevel::ELsev_zeroSeverity:
37 case mf::ELseverityLevel::ELsev_unspecified:
41 case mf::ELseverityLevel::ELsev_info:
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:
52 case mf::ELseverityLevel::ELsev_error:
53 # if MESSAGEFACILITY_HEX_VERSION < 0x20002 // v2_00_02 is s50, pre v2_00_02 is s48
54 case mf::ELseverityLevel::ELsev_error2:
55 case mf::ELseverityLevel::ELsev_next:
56 case mf::ELseverityLevel::ELsev_severe2:
57 case mf::ELseverityLevel::ELsev_abort:
58 case mf::ELseverityLevel::ELsev_fatal:
60 case mf::ELseverityLevel::ELsev_severe:
61 case mf::ELseverityLevel::ELsev_highestSeverity:
69 void qt_mf_msg::setMessage(std::string prefix,
int iteration, std::string msg)
71 sourceType_ = QString(prefix.c_str()).toHtmlEscaped();
72 sourceSequence_ = iteration;
73 msg_ = QString(msg.c_str()).toHtmlEscaped();
76 void qt_mf_msg::updateText()
78 text_ = QString(
"<font color=");
80 QString sev_name =
"Error";
84 text_ += QString(
"#505050>");
85 color_.setRgb(80, 80, 80);
90 text_ += QString(
"#008000>");
91 color_.setRgb(0, 128, 0);
96 text_ += QString(
"#E08000>");
97 color_.setRgb(224, 128, 0);
102 text_ += QString(
"#FF0000>");
103 color_.setRgb(255, 0, 0);
110 shortText_ = QString(text_);
111 shortText_ += QString(
"<pre style=\"margin-top: 0; margin-bottom: 0;\">");
113 shortText_ += QString(
"</pre></font>");
116 size_t constexpr SIZE{ 144 };
119 strftime(ts,
sizeof(ts),
"%d-%b-%Y %H:%M:%S %Z", localtime_r(&time_.tv_sec, &timebuf));
122 text_ += QString(
"<pre style=\"width: 100%;\">")
123 + sev_name.toHtmlEscaped() +
" / "
124 + cat_.toHtmlEscaped() +
"<br>"
125 + QString(ts).toHtmlEscaped() +
"<br>"
126 + host_.toHtmlEscaped() +
" ("
127 + hostaddr_ +
")<br>"
128 + sourceType_ +
" " + QString::number(sourceSequence_) +
" / "
132 text_ += QString(
" / ") + file_ + QString(
":") + line_;
134 text_ += QString(
"<br>")
135 + application_ +
" / "
141 text_ += QString(
"</font>");
qt_mf_msg(std::string hostname, std::string category, std::string application, pid_t pid, timeval time)
Construct a qt_mf_msg