1 #include "messagefacility/Utilities/ELseverityLevel.h"
3 #include "messagefacility/MessageService/ELdestination.h"
4 #include "mfextensions/Receivers/qt_mf_msg.hh"
8 size_t qt_mf_msg::sequence = 0;
10 qt_mf_msg::qt_mf_msg(
const std::string& hostname,
const std::string& category,
const 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 int sevid = sev.getLevel();
30 case mf::ELseverityLevel::ELsev_success:
31 case mf::ELseverityLevel::ELsev_zeroSeverity:
32 case mf::ELseverityLevel::ELsev_unspecified:
36 case mf::ELseverityLevel::ELsev_info:
40 case mf::ELseverityLevel::ELsev_warning:
44 case mf::ELseverityLevel::ELsev_error:
45 case mf::ELseverityLevel::ELsev_severe:
46 case mf::ELseverityLevel::ELsev_highestSeverity:
57 sourceType_ = QString(prefix.c_str()).toHtmlEscaped();
58 sourceSequence_ = iteration;
59 msg_ = QString(msg.c_str()).toHtmlEscaped();
64 text_ = QString(
"<font color=");
66 QString sev_name =
"Error";
70 text_ += QString(
"#505050>");
71 color_.setRgb(80, 80, 80);
76 text_ += QString(
"#008000>");
77 color_.setRgb(0, 128, 0);
82 text_ += QString(
"#E08000>");
83 color_.setRgb(224, 128, 0);
88 text_ += QString(
"#FF0000>");
89 color_.setRgb(255, 0, 0);
97 shortText_ = text_ +
"<pre style=\"margin-top: 0; margin-bottom: 0;\">" + msg_ +
"</pre></font>";
99 size_t constexpr SIZE{144};
102 strftime(ts,
sizeof(ts),
"%d-%b-%Y %H:%M:%S %Z", localtime_r(&time_.tv_sec, &timebuf));
104 text_ += QString(
"<pre style=\"width: 100%;\">") + sev_name +
" / " + cat_.toHtmlEscaped() +
"<br>" +
105 QString(ts).toHtmlEscaped() +
"<br>" + host_.toHtmlEscaped() +
" (" + hostaddr_ +
")<br>" + sourceType_ +
106 " " + QString::number(sourceSequence_) +
" / " +
"PID " + pid_;
108 if (file_ !=
"") text_ += QString(
" / ") + file_ +
":" + line_;
110 text_ += QString(
"<br>") + application_ +
" / " + module_ +
" / " + eventID_ +
"<br>" + msg_ +
"</pre></font>";
void updateText()
Parse fields and create HTML string representing message
void setMessage(const std::string &prefix, int iteration, const std::string &msg)
Set the message
qt_mf_msg()
Default message constructor.
void setSeverity(mf::ELseverityLevel sev)
Set the Severity of the message (MF levels)