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()

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 31 of file Logging.hpp.

32 {
33 // need to get tricky to short circuit DEBUG message (at "level 1") about
34 // libmtsStreams.so: cannot open shared object file: No such file or directory
46
47 // creates variables for application awearness
48 setenv("DUNEDAQ_SESSION", session.c_str(), 1);
49 setenv("DUNEDAQ_APPLICATION_NAME", application.c_str(), 1);
50
51 // set defaults with 0=no override
52 setenv("DUNEDAQ_ERS_FATAL", "erstrace,lstderr", 0);
53 setenv("DUNEDAQ_ERS_ERROR", "erstrace,throttle(30,100),lstderr", 0);
54 setenv("DUNEDAQ_ERS_WARNING", "erstrace,throttle(30,100),lstderr", 0);
55 setenv("DUNEDAQ_ERS_INFO", "erstrace,lstdout", 0);
56 setenv("DUNEDAQ_ERS_LOG", "lstdout", 0);
57 setenv("DUNEDAQ_ERS_DEBUG", "lstdout", 0);
58 std::vector<std::string> envvars = {
59 "DUNEDAQ_ERS_FATAL", "DUNEDAQ_ERS_ERROR", "DUNEDAQ_ERS_WARNING", "DUNEDAQ_ERS_INFO"
60 };
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
76 // libmtsStreams.so: cannot open shared object file: No such file or directory
77 // by only setting debug_level AFTER first ers::debug message
78 // setenv("DUNEDAQ_ERS_DEBUG_LEVEL","63",0);
79 ers::LocalContext lc("logging package", __FILE__, __LINE__, __func__, 0 /*no_stack*/);
80 int lvl = 100;
81 ers::InternalMessage msg(lc,
82 "Logger setup(...) ers::debug level " + std::to_string(lvl) +
83 " -- seems to come out level 0 (with ERS version v0_26_00d) ???");
84 msg.set_severity(ers::Severity(ers::Debug, lvl));
85 ers::debug(msg, lvl); // still comes out as level 0 ???
87 char* cp;
88 if ((cp = getenv("DUNEDAQ_ERS_DEBUG_LEVEL")) && *cp) {
89 int lvl = strtoul(cp, nullptr, 0) + TLVL_DEBUG;
90 if (lvl > 63)
91 lvl = 63;
92 // TRACE_CNTL("lvlmskSg",(1ULL<<lvl)-1); // this sets traceTID to id of "Logger"
93 uint64_t msk = ((1ULL << lvl) - 1) | (1ULL << lvl);
94 std::string mskstr = std::to_string(msk) + ",0x0";
95 setenv("TRACE_LVLS", mskstr.c_str(), 0);
96 }
97 }
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:91
@ Debug
Definition Severity.hpp:38

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