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 275 of file Logger.hxx.

◆ _tlog_ARG3

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

Definition at line 276 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:274
#define COMMA_IF_PARENS(...)
Definition Logger.hxx:268
#define LOG2_(value, value1)
Definition Logger.hxx:267
#define LOG0_()
Definition Logger.hxx:265
#define LOG1_(value)
Definition Logger.hxx:266
#define LPAREN
Definition Logger.hxx:269
#define EXPAND_(...)
Definition Logger.hxx:270

Definition at line 271 of file Logger.hxx.

271#define CHOOSE_(...) EXPAND_(LOG__ LPAREN \
272 __VA_ARGS__ COMMA_IF_PARENS __VA_ARGS__ COMMA_IF_PARENS __VA_ARGS__ (), \
273 LOG2_, impossible, LOG2_, LOG1_, LOG0_, LOG1_, ))

◆ COMMA_IF_PARENS

#define COMMA_IF_PARENS ( ...)
Value:
,

Definition at line 268 of file Logger.hxx.

◆ EXPAND_

#define EXPAND_ ( ...)
Value:
__VA_ARGS__

Definition at line 270 of file Logger.hxx.

◆ LOG0_

#define LOG0_ ( )

Definition at line 265 of file Logger.hxx.

◆ LOG1_

#define LOG1_ ( value)
Value:
value,

Definition at line 266 of file Logger.hxx.

◆ LOG2_

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

Definition at line 267 of file Logger.hxx.

◆ LOG__

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

Definition at line 274 of file Logger.hxx.

◆ LPAREN

#define LPAREN   (

Definition at line 269 of file Logger.hxx.

◆ SL_FRC

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

Definition at line 263 of file Logger.hxx.

Function Documentation

◆ erstrace_user() [1/2]

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

Definition at line 79 of file Logger.hxx.

80{
81 va_list ap;
82 va_start(ap, msg);
83 verstrace_user(tvp, TID, lvl, insert, file, line, function, nargs, msg, ap);
84 va_end(ap);
85}
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]

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,
... )
static

Definition at line 90 of file Logger.hxx.

91{
92 va_list ap;
93 va_start(ap, msg);
94 verstrace_user(tvp, TID, lvl, insert, file, line, function, nargs, &msg[0], ap);
95 va_end(ap);
96} /* trace */

◆ operator<<() [1/2]

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

Definition at line 120 of file Logger.hxx.

121{
122 if (x.do_m) {
123 x.line_ = r.context().line_number();
124 x.msg_append(r.message().c_str());
125 // MAY NEED TO APPEND CHAINED ISSUE???
126 }
127 if (x.do_s) {
128 if (x.lvl_==TLVL_INFO) ers::info( r ); \
129 else if (x.lvl_==TLVL_LOG) ers::log( r ); \
130 else ers::debug( r, x.lvl_-TLVL_DEBUG ); \
131 x.do_s = 0;
132 }
133}
void info(const Issue &issue)
Definition ers.hpp:95
void log(const Issue &issue)
Definition ers.hpp:102
void debug(const Issue &issue, int level=debug_level())
Definition ers.hpp:74

◆ operator<<() [2/2]

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

Definition at line 102 of file Logger.hxx.

103{
104 if (x.do_m) {
105 x.line_ = r.context().line_number();
106 x.msg_append(r.message().c_str());
107 // MAY NEED TO APPEND CHAINED ISSUE???
108 // const ers::Issue *issp = &r;
109 // while ((issp=issp->cause())) {
110 // }
111 }
112 if (x.do_s) {
113 if (x.lvl_==TLVL_INFO) ers::info( r ); \
114 else if (x.lvl_==TLVL_LOG) ers::log( r ); \
115 else ers::debug( r, x.lvl_-TLVL_DEBUG ); \
116 x.do_s = 0;
117 }
118}

◆ verstrace_user()

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

Definition at line 22 of file Logger.hxx.

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