LCOV - code coverage report
Current view: top level - logging/test/apps - six_streams.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 29 0
Test Date: 2026-10-11 15:05:20 Functions: 0.0 % 8 0

            Line data    Source code
       1              : /**
       2              :  * @file six_streams.cxx - another basic demonstration - can experiment with setup vs. env.var config
       3              :  *
       4              :  * This is part of the DUNE DAQ Application Framework, copyright 2020.
       5              :  * Licensing/copyright details are in the COPYING file that you should have
       6              :  * received with this code.
       7              :  *
       8              :  */
       9              : const char* usage = R"foo(
      10              :   usage: %s [option]    # demonstrate six logging levels
      11              : example: %s
      12              : options:
      13              :  --help, -h       - print this help
      14              :  --no-setup, -n   - do not call Logging.setup() which integrates ERS and TRACE
      15              : )foo"
      16              :                     "\n";
      17              : #define USAGE() printf(usage, basename(argv[0]), basename(argv[0]))
      18              : 
      19              : #include <getopt.h> // getopt_long
      20              : #include <libgen.h> // basename
      21              : 
      22              : #include <ers/SampleIssues.hpp>
      23              : #include <logging/Logging.hpp>
      24              : #include <string>
      25              : 
      26              : int
      27            0 : main(int argc, char* argv[])
      28              : {
      29            0 :   int opt_help = 0, do_setup = 1;
      30            0 :   while (true) {
      31            0 :     static struct option long_options[] = { { "help", no_argument, nullptr, 'h' },
      32              :                                             { "no-setup", no_argument, nullptr, 'n' },
      33              :                                             { nullptr, 0, nullptr, 0 } };
      34            0 :     int opt = getopt_long(argc, argv, "?hn", long_options, nullptr);
      35            0 :     if (opt == -1)
      36              :       break;
      37            0 :     switch (opt) {
      38              :       case '?':
      39              :       case 'h':
      40              :         opt_help = 1;
      41              :         break;
      42              :       case 'n':
      43            0 :         do_setup = 0;
      44              :         break;
      45            0 :       default:
      46            0 :         dunedaq::logging::Logging::setup("test", "six_streams");
      47            0 :         TLOG() << "?? getopt returned character code 0" << std::oct << opt;
      48            0 :         opt_help = 1;
      49              :     }
      50            0 :   }
      51            0 :   if (opt_help) {
      52            0 :     USAGE();
      53            0 :     exit(0);
      54              :   }
      55              : 
      56            0 :   if (do_setup) {
      57            0 :     dunedaq::logging::Logging::setup("test",
      58              :                                      "six_stream"); // either do this or export DUNEDAQ_ERS_FATAL=erstrace,lstderr
      59              :                                                     // DUNEDAQ_ERS_ERROR='erstrace,throttle(30,100),lstderr'
      60              :                                                     // DUNEDAQ_ERS_WARNING='erstrace,throttle(30,100),lstderr'
      61              :   }
      62              : 
      63              :   // usually, one of these (group of 3) do not come first
      64            0 :   ers::fatal(ers::FileDoesNotExist(ERS_HERE, "fatal file"));
      65            0 :   ers::error(ers::FileDoesNotExist(ERS_HERE, "error file"));
      66            0 :   ers::warning(ers::FileDoesNotExist(ERS_HERE, "warning file"));
      67            0 :   ers::info(ers::FileDoesNotExist(ERS_HERE, "info file"));
      68            0 :   TLOG() << "Hello log stream";
      69            0 :   TLOG_DEBUG(2) << "debug 2 - first debug (to ers::debug stream) appears to always get lvl 0.";
      70            0 :   TLOG_DEBUG(1) << "debug 1 - first debug (to ers::debug stream) appears to always get lvl 0.";
      71            0 :   TLOG_DEBUG(0) << "debug 0 - stream arg=" << 3;
      72            0 :   TLOG_DEBUG(200) << "debug 200-debug levels above 55 will be changed to 55; first debug appear to always get lvl 0.";
      73            0 :   TLOG_DEBUG(-20) << "debug -20-debug levels below  0 will be changed to  0";
      74              : 
      75            0 :   return (0);
      76              : } // main
        

Generated by: LCOV version 2.0-1