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

            Line data    Source code
       1              : // #define NDEBUG
       2              : 
       3              : #define MF_DEBUG
       4              : 
       5              : #include <cstdio>
       6              : #include <cstdlib>
       7              : #include <fstream>
       8              : #include <iostream>
       9              : #include <sstream>
      10              : #include "fhiclcpp/ParameterSet.h"
      11              : 
      12              : #include "messagefacility/MessageLogger/MessageLogger.h"
      13              : 
      14            0 : void anotherLogger()
      15              : {
      16              :         // Set module name
      17            0 :         mf::SetApplicationName("anotherLogger");
      18              : 
      19            0 :         mf::LogWarning("warn1 | warn2") << "Followed by a WARNING message.";
      20            0 :         mf::LogDebug("debug") << "The debug message in the other thread";
      21            0 : }
      22              : 
      23            0 : int main()
      24              : {
      25              :         try
      26              :         {
      27              :                 // Start MessageFacility Service
      28            0 :                 std::ostringstream ss;
      29            0 :                 std::ifstream logfhicl("MessageFacility.cfg");
      30            0 :                 if (logfhicl.is_open())
      31              :                 {
      32            0 :                         std::stringstream fhiclstream;
      33            0 :                         fhiclstream << logfhicl.rdbuf();
      34            0 :                         ss << fhiclstream.str();
      35            0 :                 }
      36              : 
      37            0 :                 std::string pstr(ss.str());
      38            0 :                 fhicl::ParameterSet pset = fhicl::ParameterSet::make(pstr);
      39            0 :                 mf::StartMessageFacility(pset);
      40            0 :         }
      41            0 :         catch (std::exception& e)
      42              :         {
      43              :                 std::cerr << "Catched\n"
      44            0 :                           << e.what();
      45            0 :                 exit(-1);
      46            0 :         }
      47              : 
      48              :         // Set module name for the main thread
      49            0 :         mf::SetApplicationName("mftest");
      50              : 
      51              :         // Start up another logger in a seperate thread
      52              :         // boost::thread loggerThread(anotherLogger);
      53              : 
      54              :         // Issue messages with different severity levels
      55              :         // mf::LogError("err1|err2") << "This is an ERROR message.";
      56              :         // mf::LogWarning("warning") << "Followed by a WARNING message.";
      57              : 
      58              :         // Switch context
      59              : 
      60              :         // mf::SwitchChannel(2);
      61              : 
      62              :         char buf[100];
      63              : 
      64              :         // Log Debugs
      65            0 :         for (int i = 0; i < 2; ++i)
      66              :         {
      67            0 :                 if (i % 1000 == 0)
      68              :                 {
      69            0 :                         sprintf(buf, "mftest-%d", i);
      70            0 :                         mf::SetApplicationName(buf);
      71              :                 }
      72              : 
      73            0 :                 mf::LogError("catError") << "Error information. " << i;
      74            0 :                 mf::LogWarning("catWarning") << "Warning information. " << i;
      75            0 :                 mf::LogInfo("catInfo") << "Info information. " << i;
      76              : 
      77            0 :                 MF_LOG_DEBUG("debug") << "DEBUG information. " << i;
      78              : 
      79              :                 // sleep(1);
      80            0 :                 usleep(400000);
      81              :         }
      82              : 
      83              :         // Thread join
      84              :         // loggerThread.join();
      85              : 
      86            0 :         mf::LogStatistics();
      87              : 
      88              :         // sleep(2);
      89              : 
      90            0 :         return 0;
      91              : }
        

Generated by: LCOV version 2.0-1