DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Logger.hxx File Reference
#include <stdlib.h>
#include <ers/OutputStream.hpp>
Include dependency graph for Logger.hxx:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ers::erstraceStream

Namespaces

namespace  ers

Macros

#define SL_FRC(lvl)
#define LOG0_()
#define LOG1_(value)
#define LOG2_(value, value1)
#define COMMA_IF_PARENS(...)
#define LPAREN   (
#define EXPAND_(...)
#define CHOOSE_(...)
#define LOG__(a0, a1, a2, a3, a4, a5, arg, ...)
#define _tlog_ARG2(a1, a2, ...)
#define _tlog_ARG3(a1, a2, a3, ...)

Functions

static void verstrace_user (struct timeval *, int TID, uint8_t lvl, const char *insert, const char *file, int line, const char *function, uint16_t nargs, const char *msg, va_list ap)
static SUPPRESS_NOT_USED_WARN void erstrace_user (struct timeval *tvp, int TID, uint8_t lvl, const char *insert, const char *file, int line, const char *function, uint16_t nargs, const char *msg,...)
static SUPPRESS_NOT_USED_WARN void erstrace_user (struct timeval *tvp, int TID, uint8_t lvl, const char *insert, const char *file, int line, const char *function, uint16_t nargs, const std::string &msg,...)
void operator<< (TraceStreamer &x, const ers::Issue &r)
void operator<< (TraceStreamer &x, const ers::InternalMessage &r)

Macro Definition Documentation

◆ _tlog_ARG2

#define _tlog_ARG2 ( a1,
a2,
... )
Value:
tlog_ARG2(a1, a2, __VA_ARGS__)

Definition at line 321 of file Logger.hxx.

◆ _tlog_ARG3

#define _tlog_ARG3 ( a1,
a2,
a3,
... )
Value:
tlog_ARG3(a1, a2, a3, __VA_ARGS__)

Definition at line 322 of file Logger.hxx.

◆ CHOOSE_

#define CHOOSE_ ( ...)
Value:
__VA_ARGS__ COMMA_IF_PARENS __VA_ARGS__ COMMA_IF_PARENS __VA_ARGS__ (), \
LOG2_, impossible, LOG2_, LOG1_, LOG0_, LOG1_, ))
#define LOG__(a0, a1, a2, a3, a4, a5, arg,...)
Definition Logger.hxx:320
#define COMMA_IF_PARENS(...)
Definition Logger.hxx:314
#define LOG2_(value, value1)
Definition Logger.hxx:313
#define LOG0_()
Definition Logger.hxx:311
#define LOG1_(value)
Definition Logger.hxx:312
#define LPAREN
Definition Logger.hxx:315
#define EXPAND_(...)
Definition Logger.hxx:316

Definition at line 317 of file Logger.hxx.

◆ COMMA_IF_PARENS

#define COMMA_IF_PARENS ( ...)
Value:
,

Definition at line 314 of file Logger.hxx.

◆ EXPAND_

#define EXPAND_ ( ...)
Value:
__VA_ARGS__

Definition at line 316 of file Logger.hxx.

◆ LOG0_

#define LOG0_ ( )

Definition at line 311 of file Logger.hxx.

◆ LOG1_

#define LOG1_ ( value)
Value:
value,

Definition at line 312 of file Logger.hxx.

◆ LOG2_

#define LOG2_ ( value,
value1 )
Value:
value, value1,

Definition at line 313 of file Logger.hxx.

◆ LOG__

#define LOG__ ( a0,
a1,
a2,
a3,
a4,
a5,
arg,
... )
Value:
arg

Definition at line 320 of file Logger.hxx.

◆ LPAREN

#define LPAREN   (

Definition at line 315 of file Logger.hxx.

◆ SL_FRC

#define SL_FRC ( lvl)
Value:
((lvl) >= 0 && (lvl) < TLVL_DEBUG)

Definition at line 309 of file Logger.hxx.

Function Documentation

◆ erstrace_user() [1/2]

SUPPRESS_NOT_USED_WARN void erstrace_user ( struct timeval * tvp,
int TID,
uint8_t lvl,
const char * insert,
const char * file,
int line,
const char * function,
uint16_t nargs,
const char * msg,
... )
static

Definition at line 87 of file Logger.hxx.

97{
98 va_list ap;
99 va_start(ap, msg);
100 verstrace_user(tvp, TID, lvl, insert, file, line, function, nargs, msg, ap);
101 va_end(ap);
102}
static void verstrace_user(struct timeval *, int TID, uint8_t lvl, const char *insert, const char *file, int line, const char *function, uint16_t nargs, const char *msg, va_list ap)
Definition Logger.hxx:22

◆ erstrace_user() [2/2]

SUPPRESS_NOT_USED_WARN void erstrace_user ( struct timeval * tvp,
int TID,
uint8_t lvl,
const char * insert,
const char * file,
int line,
const char * function,
uint16_t nargs,
const std::string & msg,
... )
static

Definition at line 108 of file Logger.hxx.

118{
119 va_list ap;
120 va_start(ap, msg);
121 verstrace_user(tvp, TID, lvl, insert, file, line, function, nargs, &msg[0], ap);
122 va_end(ap);
123} /* trace */

◆ operator<<() [1/2]

void operator<< ( TraceStreamer & x,
const ers::InternalMessage & r )
inline

Definition at line 149 of file Logger.hxx.

151{
152 if (x.do_m) {
153 x.line_ = r.context().line_number();
154 x.msg_append(r.message().c_str());
155 // MAY NEED TO APPEND CHAINED ISSUE???
156 }
157 if (x.do_s) {
158 if (x.lvl_ == TLVL_INFO)
159 ers::info(r);
160 else if (x.lvl_ == TLVL_LOG)
161 ers::log(r);
162 else
163 ers::debug(r, x.lvl_ - TLVL_DEBUG);
164 x.do_s = 0;
165 }
166}
void info(const Issue &issue)
Definition ers.hpp:121
void log(const Issue &issue)
Definition ers.hpp:131
void debug(const Issue &issue, int level=debug_level())
Definition ers.hpp:91

◆ operator<<() [2/2]

void operator<< ( TraceStreamer & x,
const ers::Issue & r )
inline

Definition at line 127 of file Logger.hxx.

129{
130 if (x.do_m) {
131 x.line_ = r.context().line_number();
132 x.msg_append(r.message().c_str());
133 // MAY NEED TO APPEND CHAINED ISSUE???
134 // const ers::Issue *issp = &r;
135 // while ((issp=issp->cause())) {
136 // }
137 }
138 if (x.do_s) {
139 if (x.lvl_ == TLVL_INFO)
140 ers::info(r);
141 else if (x.lvl_ == TLVL_LOG)
142 ers::log(r);
143 else
144 ers::debug(r, x.lvl_ - TLVL_DEBUG);
145 x.do_s = 0;
146 }
147}

◆ verstrace_user()

void verstrace_user ( struct timeval * ,
int TID,
uint8_t lvl,
const char * insert,
const char * file,
int line,
const char * function,
uint16_t nargs,
const char * msg,
va_list ap )
static

Definition at line 22 of file Logger.hxx.

32{
33
34 size_t printed = 0;
35 int retval;
36 const char* outp;
37 char obuf[TRACE_USER_MSGMAX];
38
39 if ((insert && (printed = strlen(insert))) || nargs) {
40 /* check insert 1st to make sure printed is set */
41 // assume insert is smaller than obuf
42 if (printed) {
43 retval = snprintf(obuf, sizeof(obuf), "%s ", insert);
44 printed = TRACE_SNPRINTED(retval, sizeof(obuf));
45 }
46 if (nargs) {
47 retval =
48 vsnprintf(&(obuf[printed]), sizeof(obuf) - printed, msg, ap); // man page say obuf will always be terminated
49 printed += TRACE_SNPRINTED(retval, sizeof(obuf) - printed);
50 } else {
51 /* don't do any parsing for format specifiers in the msg -- tshow will
52 also know to do this on the memory side of things */
53 retval = snprintf(&(obuf[printed]), sizeof(obuf) - printed, "%s", msg);
54 printed += TRACE_SNPRINTED(retval, sizeof(obuf) - printed);
55 }
56 if (obuf[printed - 1] == '\n')
57 obuf[printed - 1] = '\0'; // DONE w/ printed (don't need to decrement
58 outp = obuf;
59 } else {
60 if (msg[strlen(msg) - 1] == '\n') { // need to copy to remove the trailing nl
61 retval = snprintf(obuf, sizeof(obuf), "%s", msg);
62 printed = TRACE_SNPRINTED(retval, sizeof(obuf));
63 if (obuf[printed - 1] == '\n')
64 obuf[printed - 1] = '\0'; // DONE w/ printed (don't need to decrement
65 outp = obuf;
66 } else
67 outp = msg;
68 }
69 // LocalContext args: 1-"package_name" 2-"file" 3-"line" 4-"pretty_function" 5-"include_stack"
70 ers::LocalContext lc(reinterpret_cast<char*>(idx2namsPtr(TID)), file, line, function, DEBUG_FORCED);
71 // std::ostringstream ers_report_impl_out_buffer;
72 // ers_report_impl_out_buffer << outp;
73 if (lvl < TLVL_DEBUG) { // NOTE: at least currently, TLVL_LOG is numerically 1 less than TLVL_DEBUG
74 // auto d = std::chrono::seconds{tvp->tv_sec} + std::chrono::microseconds{tvp->tv_usec};
76 // std::chrono::system_clock::time_point tp{d};
77 // PROTECTED - ers::Issue iss( ers::Issue( ers::Severity(ers::Log), tp, lc, outp, std::vector<std::string>(),
78 // std::map<std::string,std::string>(), nullptr ));
79 ers::log(ers::InternalMessage(lc, outp));
80 } else {
81 ers::debug(ers::InternalMessage(lc, outp), lvl - TLVL_DEBUG);
82 }
83}