LCOV - code coverage report
Current view: top level - /opt/artdaq/srcs/artdaq-mfextensions/ErrorHandler/MessageAnalyzer - ma_utils.h (source / functions) Coverage Total Hit
Test: artdaq.info.cleaned Lines: 0.0 % 29 0
Test Date: 2025-09-04 00:45:34 Functions: 0.0 % 3 0

            Line data    Source code
       1              : #ifndef ERROR_HANDLER_UTILS_H
       2              : #define ERROR_HANDLER_UTILS_H
       3              : 
       4              : #include "ErrorHandler/MessageAnalyzer/ma_types.h"
       5              : #include "messagefacility/Utilities/ELseverityLevel.h"
       6              : 
       7              : namespace novadaq {
       8              : namespace errorhandler {
       9              : 
      10              : inline std::string
      11              : trim_hostname(std::string const& host);
      12              : 
      13              : inline node_type_t
      14              : get_source_from_msg(std::string& src, qt_mf_msg const& msg);
      15              : 
      16              : inline std::string
      17              : get_message_type_str(message_type_t type);
      18              : 
      19              : inline sev_code_t get_sev_from_string(std::string const& sev);
      20              : 
      21              : }  // end of namespace errorhandler
      22              : }  // end of namespace novadaq
      23              : 
      24              : // ------------------------------------------------------------------
      25              : // misc. utilities
      26              : 
      27              : std::string
      28              : novadaq::errorhandler::trim_hostname(std::string const& host)
      29              : {
      30              :         size_t pos = host.find('.');
      31              :         if (pos == std::string::npos)
      32              :                 return host;
      33              :         else
      34              :                 return host.substr(0, pos);
      35              : }
      36              : 
      37              : /**
      38              :  * @brief Determine the source type of the message
      39              :  * @param[out] src Resolved Source
      40              :  * @param msg Message object
      41              :  * @return node_type_t indicating the type of the source
      42              :  */
      43              : novadaq::errorhandler::node_type_t
      44            0 : novadaq::errorhandler::get_source_from_msg(std::string& src, qt_mf_msg const& msg)
      45              : {
      46            0 :         src = msg.app().toStdString();
      47            0 :         return Framework;
      48              : }
      49              : 
      50              : std::string
      51            0 : novadaq::errorhandler::get_message_type_str(message_type_t type)
      52              : {
      53            0 :         switch (type)
      54              :         {
      55            0 :                 case MSG_SYSTEM:
      56            0 :                         return "SYSTEM";
      57            0 :                 case MSG_ERROR:
      58            0 :                         return "ERROR";
      59            0 :                 case MSG_WARNING:
      60            0 :                         return "WARNING";
      61            0 :                 case MSG_INFO:
      62            0 :                         return "INFO";
      63            0 :                 case MSG_DEBUG:
      64            0 :                         return "DEBUG";
      65            0 :                 default:
      66            0 :                         return "UNKNOWN";
      67              :         }
      68              : }
      69              : 
      70            0 : sev_code_t novadaq::errorhandler::get_sev_from_string(std::string const& sev)
      71              : {
      72            0 :         mf::ELseverityLevel elss(sev);
      73              : 
      74            0 :         int sevid = elss.getLevel();
      75              : 
      76            0 :         switch (sevid)
      77              :         {
      78            0 :                 case mf::ELseverityLevel::ELsev_success:
      79              :                 case mf::ELseverityLevel::ELsev_zeroSeverity:
      80              :                 case mf::ELseverityLevel::ELsev_unspecified:
      81            0 :                         return SDEBUG;
      82              : 
      83            0 :                 case mf::ELseverityLevel::ELsev_info:
      84            0 :                         return SINFO;
      85              : 
      86            0 :                 case mf::ELseverityLevel::ELsev_warning:
      87            0 :                         return SWARNING;
      88              : 
      89            0 :                 case mf::ELseverityLevel::ELsev_error:
      90              :                 case mf::ELseverityLevel::ELsev_severe:
      91              :                 case mf::ELseverityLevel::ELsev_highestSeverity:
      92              :                 default:
      93            0 :                         return SERROR;
      94              :         }
      95              : }
      96              : 
      97              : #endif
        

Generated by: LCOV version 2.0-1