DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::logging::Logging Class Reference

The Logger class defines the interface necessary to configure central logging within a DAQ Application. More...

#include <Logging.hpp>

Classes

class  InternalMessage
 

Static Public Member Functions

static void setup (const std::string &session, const std::string &application)
 Setup the Logger service Currently no args.
 

Detailed Description

The Logger class defines the interface necessary to configure central logging within a DAQ Application.

Definition at line 24 of file Logging.hpp.

Member Function Documentation

◆ setup()

static void dunedaq::logging::Logging::setup ( const std::string & session,
const std::string & application )
inlinestatic

Setup the Logger service Currently no args.

Example: production env: export DUNEDAQ_ERS_ERROR="erstrace,throttle(30,100),lstderr,mts" export DUNEDAQ_ERS_FATAL="erstrace,lstderr,mts" export DUNEDAQ_ERS_WARNING="erstrace,throttle(30,100),lstderr,mts" export DUNEDAQ_ERS_INFO="erstrace,throttle(30,100),lstdout,mts"

export DUNEDAQ_ERS_LOG="lstdout" export DUNEDAQ_ERS_DEBUG="lstdout"

export DUNEDAQ_ERS_STREAM_LIBS="mtsStreams"

Definition at line 32 of file Logging.hpp.

34 {
35 // need to get tricky to short circuit DEBUG message (at "level 1") about
36 // libmtsStreams.so: cannot open shared object file: No such file or directory
49 // creates variables for application awearness
50 setenv("DUNEDAQ_SESSION", session.c_str(), 1);
51 setenv("DUNEDAQ_APPLICATION_NAME", application.c_str(), 1);
52
53 // set defaults with 0=no override
54 setenv("DUNEDAQ_ERS_FATAL", "erstrace,lstderr",0);
55 setenv("DUNEDAQ_ERS_ERROR", "erstrace,throttle(30,100),lstderr",0);
56 setenv("DUNEDAQ_ERS_WARNING","erstrace,throttle(30,100),lstderr",0);
57 setenv("DUNEDAQ_ERS_INFO", "erstrace,lstdout",0);
58 setenv("DUNEDAQ_ERS_LOG", "lstdout",0);
59 setenv("DUNEDAQ_ERS_DEBUG", "lstdout",0);
60 std::vector<std::string> envvars = {"DUNEDAQ_ERS_FATAL","DUNEDAQ_ERS_ERROR","DUNEDAQ_ERS_WARNING","DUNEDAQ_ERS_INFO"};
61 for (std::string& envvar : envvars) {
62 char *ecp = getenv(envvar.c_str());
63 if (strncmp(ecp,"erstrace",8) != 0) {
64 std::string newval = "erstrace," + std::string(ecp);
65 setenv(envvar.c_str(),newval.c_str(),1);
66 }
67 }
68
69 //setenv("DUNEDAQ_APPLICATION_NAME","XYZZY",0);
70 // std::ostringstream out;
71 // out << (1ULL<<(TLVL_DEBUG+2))-1;
72 // setenv("TRACE_LVLM",(out.str()+",0").c_str(),0);
73
74 // Avoid ERS_INTERNAL_DEBUG( 1, "Library " << MRSStreamLibraryName << " can not be loaded because " << ex.reason() )
75 // DEBUG_1 [ers::PluginManager::PluginManager(...) at ...Library mtsStreams can not be loaded because libmtsStreams.so: cannot open shared object file: No such file or directory
76 // by only setting debug_level AFTER first ers::debug message
77 //setenv("DUNEDAQ_ERS_DEBUG_LEVEL","63",0);
78 ers::LocalContext lc( "logging package", __FILE__, __LINE__, __func__, 0/*no_stack*/ );
79 int lvl=100;
80 ers::InternalMessage msg(lc,"Logger setup(...) ers::debug level "+std::to_string(lvl)+" -- seems to come out level 0 (with ERS version v0_26_00d) ???");
81 msg.set_severity( ers::Severity( ers::Debug, lvl ) );
82 ers::debug(msg,lvl); // still comes out as level 0 ???
84 char *cp;
85 if ((cp=getenv("DUNEDAQ_ERS_DEBUG_LEVEL")) && *cp) {
86 int lvl=strtoul(cp,nullptr,0)+TLVL_DEBUG;
87 if (lvl>63) lvl=63;
88 //TRACE_CNTL("lvlmskSg",(1ULL<<lvl)-1); // this sets traceTID to id of "Logger"
89 uint64_t msk = ((1ULL<<lvl)-1) | (1ULL<<lvl);
90 std::string mskstr=std::to_string(msk);
91 setenv("TRACE_LVLS",mskstr.c_str(),0);
92 }
93 }
static Configuration & instance()
return the singleton
int debug_level() const
returns current debug level
void debug(const Issue &issue, int level=debug_level())
Definition ers.hpp:74
@ Debug
Definition Severity.hpp:26

The documentation for this class was generated from the following file: