$treeview $search $mathjax $extrastylesheet
artdaq_mfextensions
v1_03_03
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #include "messagefacility/Utilities/ELseverityLevel.h" 00002 00003 #include "messagefacility/MessageService/ELdestination.h" 00004 #include "mfextensions/Receivers/qt_mf_msg.hh" 00005 //#include "mfextensions/Extensions/MFExtensions.hh" 00006 #include <iostream> 00007 00008 size_t qt_mf_msg::sequence = 0; 00009 00010 qt_mf_msg::qt_mf_msg(std::string hostname, std::string category, std::string application, pid_t pid, timeval time) 00011 : text_(), 00012 shortText_(), 00013 color_(), 00014 sev_(SERROR), 00015 host_(QString(hostname.c_str())), 00016 cat_(QString(category.c_str())), 00017 app_(QString((application + " (" + std::to_string(pid) + ")").c_str())), 00018 time_(time), 00019 seq_(++sequence), 00020 msg_(""), 00021 application_(QString(application.c_str()).toHtmlEscaped()), 00022 pid_(QString::number(pid)) {} 00023 00024 void qt_mf_msg::setSeverity(mf::ELseverityLevel sev) { 00025 int sevid = sev.getLevel(); 00026 00027 switch (sevid) { 00028 case mf::ELseverityLevel::ELsev_success: 00029 case mf::ELseverityLevel::ELsev_zeroSeverity: 00030 case mf::ELseverityLevel::ELsev_unspecified: 00031 sev_ = SDEBUG; 00032 break; 00033 00034 case mf::ELseverityLevel::ELsev_info: 00035 sev_ = SINFO; 00036 break; 00037 00038 case mf::ELseverityLevel::ELsev_warning: 00039 sev_ = SWARNING; 00040 break; 00041 00042 case mf::ELseverityLevel::ELsev_error: 00043 case mf::ELseverityLevel::ELsev_severe: 00044 case mf::ELseverityLevel::ELsev_highestSeverity: 00045 sev_ = SERROR; 00046 break; 00047 00048 default: 00049 break; 00050 } 00051 } 00052 00053 void qt_mf_msg::setMessage(std::string prefix, int iteration, std::string msg) { 00054 sourceType_ = QString(prefix.c_str()).toHtmlEscaped(); 00055 sourceSequence_ = iteration; 00056 msg_ = QString(msg.c_str()).toHtmlEscaped(); 00057 } 00058 00059 void qt_mf_msg::updateText() { 00060 text_ = QString("<font color="); 00061 00062 QString sev_name = "Error"; 00063 switch (sev_) { 00064 case SDEBUG: 00065 text_ += QString("#505050>"); 00066 color_.setRgb(80, 80, 80); 00067 sev_name = "Debug"; 00068 break; 00069 00070 case SINFO: 00071 text_ += QString("#008000>"); 00072 color_.setRgb(0, 128, 0); 00073 sev_name = "Info"; 00074 break; 00075 00076 case SWARNING: 00077 text_ += QString("#E08000>"); 00078 color_.setRgb(224, 128, 0); 00079 sev_name = "Warning"; 00080 break; 00081 00082 case SERROR: 00083 text_ += QString("#FF0000>"); 00084 color_.setRgb(255, 0, 0); 00085 sev_name = "Error"; 00086 break; 00087 00088 default: 00089 break; 00090 } 00091 00092 shortText_ = QString(text_); 00093 shortText_ += QString("<pre style=\"margin-top: 0; margin-bottom: 0;\">"); 00094 shortText_ += msg_; 00095 shortText_ += QString("</pre></font>"); 00096 00097 size_t constexpr SIZE{144}; 00098 struct tm timebuf; 00099 char ts[SIZE]; 00100 strftime(ts, sizeof(ts), "%d-%b-%Y %H:%M:%S %Z", localtime_r(&time_.tv_sec, &timebuf)); 00101 00102 text_ += QString("<pre style=\"width: 100%;\">") + sev_name.toHtmlEscaped() + " / " + cat_.toHtmlEscaped() + "<br>" + 00103 QString(ts).toHtmlEscaped() + "<br>" + host_.toHtmlEscaped() + " (" + hostaddr_ + ")<br>" + sourceType_ + 00104 " " + QString::number(sourceSequence_) + " / " + "PID " + pid_; 00105 00106 if (file_ != "") text_ += QString(" / ") + file_ + QString(":") + line_; 00107 00108 text_ += QString("<br>") + application_ + " / " + module_ + " / " + eventID_ + "<br>" + msg_ // + "<br>" 00109 + QString("</pre>"); 00110 00111 text_ += QString("</font>"); 00112 }