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 % 27 0
Test Date: 2025-12-21 13:07:08 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""\n";
      16              : #define USAGE() printf( usage, basename(argv[0]), basename(argv[0]))
      17              : 
      18              : #include <getopt.h>             // getopt_long
      19              : #include <libgen.h>             // basename
      20              : 
      21              : #include <logging/Logging.hpp>
      22              : #include <ers/SampleIssues.hpp>
      23              : #include <string>
      24              : 
      25            0 : int main(int argc, char *argv[])
      26              : {
      27            0 :         int opt_help=0, do_setup=1;
      28            0 :         while (true) {
      29            0 :                 static struct option long_options[] = {
      30              :                         { "help",     no_argument,  nullptr,   'h' },
      31              :                         { "no-setup", no_argument,  nullptr,   'n' },
      32              :                         {  nullptr,   0,            nullptr,    0  }
      33              :                 };
      34            0 :                 int opt = getopt_long( argc, argv, "?hn",long_options, nullptr );
      35            0 :                 if (opt == -1) break;
      36            0 :                 switch (opt) {
      37              :                 case '?': case 'h': opt_help=1;     break;
      38            0 :                 case 'n':           do_setup=0;     break;
      39            0 :                 default:
      40            0 :                   dunedaq::logging::Logging::setup("test", "six_streams");
      41            0 :                   TLOG() << "?? getopt returned character code 0" << std::oct << opt;
      42            0 :                   opt_help=1;
      43              :                 }
      44            0 :         }
      45            0 :         if (opt_help) { USAGE(); exit(0); }
      46              : 
      47            0 :         if (do_setup) {
      48            0 :           dunedaq::logging::Logging::setup("test", "six_stream");   // either do this or export DUNEDAQ_ERS_FATAL=erstrace,lstderr DUNEDAQ_ERS_ERROR='erstrace,throttle(30,100),lstderr' DUNEDAQ_ERS_WARNING='erstrace,throttle(30,100),lstderr'
      49              :         }
      50              : 
      51              :         // usually, one of these (group of 3) do not come first
      52            0 :         ers::fatal(  ers::FileDoesNotExist( ERS_HERE, "fatal file" ) );
      53            0 :         ers::error(  ers::FileDoesNotExist( ERS_HERE, "error file" ) );
      54            0 :         ers::warning(ers::FileDoesNotExist( ERS_HERE, "warning file") );
      55            0 :         ers::info(   ers::FileDoesNotExist( ERS_HERE, "info file") );
      56            0 :         TLOG()   << "Hello log stream";
      57            0 :         TLOG_DEBUG(2) << "debug 2 - first debug (to ers::debug stream) appears to always get lvl 0.";
      58            0 :         TLOG_DEBUG(1) << "debug 1 - first debug (to ers::debug stream) appears to always get lvl 0.";
      59            0 :         TLOG_DEBUG(0) << "debug 0 - stream arg=" << 3;
      60            0 :     TLOG_DEBUG(200)<<"debug 200-debug levels above 55 will be changed to 55; first debug appear to always get lvl 0.";
      61            0 :     TLOG_DEBUG(-20)<<"debug -20-debug levels below  0 will be changed to  0";
      62              : 
      63            0 :         return (0);
      64              : }   // main
        

Generated by: LCOV version 2.0-1