LCOV - code coverage report
Current view: top level - /opt/artdaq/srcs/artdaq-mfextensions/mfextensions/Receivers - qt_mf_msg.cc (source / functions) Coverage Total Hit
Test: artdaq.info.cleaned Lines: 0.0 % 71 0
Test Date: 2025-09-04 00:45:34 Functions: 0.0 % 4 0

            Line data    Source code
       1              : #include "messagefacility/Utilities/ELseverityLevel.h"
       2              : 
       3              : #include "messagefacility/MessageService/ELdestination.h"
       4              : #include "mfextensions/Receivers/qt_mf_msg.hh"
       5              : // #include "mfextensions/Extensions/MFExtensions.hh"
       6              : #include <iostream>
       7              : 
       8              : size_t qt_mf_msg::sequence = 0;
       9              : 
      10            0 : qt_mf_msg::qt_mf_msg(const std::string& hostname, const std::string& category, const std::string& application, pid_t pid, timeval time)
      11            0 :     : text_()
      12            0 :     , shortText_()
      13            0 :     , color_()
      14            0 :     , sev_(SERROR)
      15            0 :     , host_(QString(hostname.c_str()))
      16            0 :     , cat_(QString(category.c_str()))
      17            0 :     , app_(QString((application + " (" + std::to_string(pid) + ")").c_str()))
      18            0 :     , time_(time)
      19            0 :     , seq_(++sequence)
      20            0 :     , msg_("")
      21            0 :     , application_(QString(application.c_str()).toHtmlEscaped())
      22            0 :     , pid_(QString::number(pid)) {}
      23              : 
      24            0 : void qt_mf_msg::setSeverity(mf::ELseverityLevel sev)
      25              : {
      26            0 :         int sevid = sev.getLevel();
      27              : 
      28            0 :         switch (sevid)
      29              :         {
      30            0 :                 case mf::ELseverityLevel::ELsev_success:
      31              :                 case mf::ELseverityLevel::ELsev_zeroSeverity:
      32              :                 case mf::ELseverityLevel::ELsev_unspecified:
      33            0 :                         sev_ = SDEBUG;
      34            0 :                         break;
      35              : 
      36            0 :                 case mf::ELseverityLevel::ELsev_info:
      37            0 :                         sev_ = SINFO;
      38            0 :                         break;
      39              : 
      40            0 :                 case mf::ELseverityLevel::ELsev_warning:
      41            0 :                         sev_ = SWARNING;
      42            0 :                         break;
      43              : 
      44            0 :                 case mf::ELseverityLevel::ELsev_error:
      45              :                 case mf::ELseverityLevel::ELsev_severe:
      46              :                 case mf::ELseverityLevel::ELsev_highestSeverity:
      47            0 :                         sev_ = SERROR;
      48            0 :                         break;
      49              : 
      50            0 :                 default:
      51            0 :                         break;
      52              :         }
      53            0 : }
      54              : 
      55            0 : void qt_mf_msg::setMessage(std::string const& prefix, int iteration, std::string const& msg)
      56              : {
      57            0 :         sourceType_ = QString(prefix.c_str()).toHtmlEscaped();
      58            0 :         sourceSequence_ = iteration;
      59            0 :         msg_ = QString(msg.c_str()).toHtmlEscaped();
      60            0 : }
      61              : 
      62            0 : void qt_mf_msg::updateText()
      63              : {
      64            0 :         text_ = QString("<font color=");
      65              : 
      66            0 :         QString sev_name = "Error";
      67            0 :         switch (sev_)
      68              :         {
      69            0 :                 case SDEBUG:
      70            0 :                         text_ += QString("#505050>");
      71            0 :                         color_.setRgb(80, 80, 80);
      72            0 :                         sev_name = "Debug";
      73            0 :                         break;
      74              : 
      75            0 :                 case SINFO:
      76            0 :                         text_ += QString("#008000>");
      77            0 :                         color_.setRgb(0, 128, 0);
      78            0 :                         sev_name = "Info";
      79            0 :                         break;
      80              : 
      81            0 :                 case SWARNING:
      82            0 :                         text_ += QString("#E08000>");
      83            0 :                         color_.setRgb(224, 128, 0);
      84            0 :                         sev_name = "Warning";
      85            0 :                         break;
      86              : 
      87            0 :                 case SERROR:
      88            0 :                         text_ += QString("#FF0000>");
      89            0 :                         color_.setRgb(255, 0, 0);
      90            0 :                         sev_name = "Error";
      91            0 :                         break;
      92              : 
      93            0 :                 default:
      94            0 :                         break;
      95              :         }
      96              : 
      97            0 :         shortText_ = text_ + "<pre style=\"margin-top: 0; margin-bottom: 0;\">" + msg_ + "</pre></font>";
      98              : 
      99            0 :         size_t constexpr SIZE{144};
     100              :         struct tm timebuf;
     101              :         char ts[SIZE];
     102            0 :         strftime(ts, sizeof(ts), "%d-%b-%Y %H:%M:%S %Z", localtime_r(&time_.tv_sec, &timebuf));
     103              : 
     104            0 :         text_ += QString("<pre style=\"width: 100%;\">") + sev_name + " / " + cat_.toHtmlEscaped() + "<br>" +
     105            0 :                  QString(ts).toHtmlEscaped() + "<br>" + host_.toHtmlEscaped() + " (" + hostaddr_ + ")<br>" + sourceType_ +
     106            0 :                  " " + QString::number(sourceSequence_) + " / " + "PID " + pid_;
     107              : 
     108            0 :         if (file_ != "") text_ += QString(" / ") + file_ + ":" + line_;
     109              : 
     110            0 :         text_ += QString("<br>") + application_ + " / " + module_ + " / " + eventID_ + "<br>" + msg_ + "</pre></font>";
     111            0 : }
        

Generated by: LCOV version 2.0-1