DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
logging
include
logging
Logging.hpp
Go to the documentation of this file.
1
8
#ifndef LOGGING_INCLUDE_LOGGING_LOGGING_HPP_
9
#define LOGGING_INCLUDE_LOGGING_LOGGING_HPP_
10
11
#include "TRACE/trace.h"
12
#include "
ers/OutputStream.hpp
"
13
#include "
ers/ers.hpp
"
14
#include <string>
15
#include <vector>
16
17
#include "
logging/internal/macro.hpp
"
18
19
namespace
dunedaq::logging
{
24
class
Logging
25
{
26
public
:
31
static
void
setup
(
const
std::string&
session
,
const
std::string& application)
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 ???
86
ers::Configuration::instance
().
debug_level
(63);
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
}
98
};
99
100
}
// namespace logging
101
102
#include "
logging/detail/Logger.hxx
"
103
104
// The following uses gnu extension of "##" connecting "," with empty __VA_ARGS__
105
// which eats "," when __VA_ARGS__ is empty.
106
// pragma GCC diagnostic ignored "-Wvariadic-macros" // doesn't seem to work.
107
// Neither does pragma GCC diagnostic ignored "-Wpedantic" // g++ -std=c++11 --help=warnings | egrep -i
108
// 'variadic|pedantic' These are last because "pragma GCC system_header" only gets undone at the end of the file. This
109
// issue is fixed in -std=c++2a
110
#if (__cplusplus < 201709L)
111
#pragma GCC system_header
112
#endif
113
114
#if TRACE_REVNUM <= 1443
115
#undef TLOG_DEBUG
116
#define TLOG_DEBUG(lvl, ...) \
117
TRACE_STREAMER(((TLVL_DEBUG + lvl) < 64) ? TLVL_DEBUG + lvl : 63, \
118
tlog_ARG2(not_used, ##__VA_ARGS__, 0, need_at_least_one), \
119
tlog_ARG3(not_used, ##__VA_ARGS__, 0, "", need_at_least_one), \
120
1, \
121
0)
122
#endif
123
124
#endif
// LOGGING_INCLUDE_LOGGING_LOGGING_HPP_
Logger.hxx
OutputStream.hpp
dunedaq::logging::Logging
The Logger class defines the interface necessary to configure central logging within a DAQ Applicatio...
Definition
Logging.hpp:25
dunedaq::logging::Logging::setup
static void setup(const std::string &session, const std::string &application)
Setup the Logger service Currently no args.
Definition
Logging.hpp:31
ers::Configuration::instance
static Configuration & instance()
return the singleton
Definition
Configuration.cpp:33
ers::Configuration::debug_level
int debug_level() const
returns current debug level
Definition
Configuration.hpp:58
ers::LocalContext
Definition
LocalContext.hpp:59
ers.hpp
macro.hpp
dunedaq::logging
Definition
Logging.hpp:19
ers::debug
void debug(const Issue &issue, int level=debug_level())
Definition
ers.hpp:91
ers::Debug
@ Debug
Definition
Severity.hpp:38
session
Definition
session.py:1
ers::Severity
Definition
Severity.hpp:47
Generated on
for DUNE-DAQ by
1.18.0