DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
ers::erstraceStream Struct Reference

#include <Logger.hxx>

Inheritance diagram for ers::erstraceStream:
[legend]
Collaboration diagram for ers::erstraceStream:
[legend]

Public Member Functions

void write (const ers::Issue &issue)
Public Member Functions inherited from ers::OutputStream
virtual ~OutputStream ()
 Sends the issue into this stream.

Additional Inherited Members

Protected Member Functions inherited from ers::OutputStream
 OutputStream ()
OutputStream & chained ()
virtual bool isNull () const

Detailed Description

Definition at line 232 of file Logger.hxx.

Member Function Documentation

◆ write()

void ers::erstraceStream::write ( const ers::Issue & issue)
inlinevirtual

Implements ers::OutputStream.

Definition at line 234 of file Logger.hxx.

235 {
236 ers::Severity sev = issue.severity();
237 uint8_t lvl_ = TLVL_DEBUG;
238 switch (sev.type) {
239 case ers::Debug:
240 lvl_ = TLVL_DEBUG + sev.rank;
241 break;
242 case ers::Log:
243 lvl_ = TLVL_LOG;
244 break;
245 case ers::Information:
246 lvl_ = TLVL_INFO;
247 break;
248 case ers::Warning:
249 lvl_ = TLVL_WARNING;
250 break;
251 case ers::Error:
252 lvl_ = TLVL_ERROR;
253 break;
254 case ers::Fatal:
255 lvl_ = TLVL_FATAL;
256 break;
257 }
258 struct
259 {
260 char tn[TRACE_TN_BUFSZ];
261 } _trc_;
262 if (TRACE_INIT_CHECK(trace_name(TRACE_NAME, issue.context().file_name(), _trc_.tn, sizeof(_trc_.tn)))) {
263 if (traceControl_rwp->mode.bits.M && (traceLvls_p[traceTID].M & TLVLMSK(lvl_))) {
264 struct timeval lclTime;
265 std::chrono::system_clock::time_point tp{ issue.ptime() };
266 // auto micros = std::chrono::duration_cast<std::chrono::microseconds>(tp.time_since_epoch());
267 std::chrono::microseconds micros = std::chrono::duration_cast<std::chrono::microseconds>(tp.time_since_epoch());
268 lclTime.tv_sec = micros.count() / 1000000;
269 lclTime.tv_usec = micros.count() % 1000000;
270 int traceID = trace_name2TID(trace_name(TRACE_NAME, issue.context().file_name(), _trc_.tn, sizeof(_trc_.tn)));
271 std::string complete_message = issue.message();
272 const ers::Issue* issp = &issue;
273 while ((issp = issp->cause())) {
274 char fbuf[0x100], tbuf[0x40];
275 int strip_ns = 1;
276 tp = issp->ptime();
277 std::chrono::milliseconds millis =
278 std::chrono::duration_cast<std::chrono::milliseconds>(tp.time_since_epoch());
279 struct tm tm_s;
280 time_t secs = millis.count() / 1000;
281 localtime_r(&secs, &tm_s);
282 if (strftime(tbuf, sizeof(tbuf), "%Y-%b-%d %H:%M:%S", &tm_s) == 0)
283 tbuf[0] = '\0';
284 complete_message += "\n\tcaused by: " + std::string(tbuf);
285 int milliseconds = millis.count() % 1000;
286 sprintf(tbuf, ",%03d ", milliseconds);
287 complete_message += std::string(tbuf);
288 trace_func_to_short_func(issp->context().function_name(), fbuf, sizeof(fbuf), strip_ns);
289 complete_message += ers::to_string(issp->severity()) + " [" + fbuf + " at " +
290 trace_path_components(issp->context().file_name(), 0) + ":" +
291 std::to_string(issp->context().line_number()) + "] " + issp->message();
292 }
293 trace(&lclTime,
294 traceID,
295 lvl_,
296 issue.context().line_number(),
297 issue.context().function_name(),
298 0 TRACE_XTRA_PASSED,
299 complete_message.c_str());
300 }
301 }
302 chained().write(issue);
303 }
virtual int line_number() const =0
virtual const char * file_name() const =0
virtual const char * function_name() const =0
const Context & context() const
Context of the issue.
Definition Issue.hpp:102
ers::Severity severity() const
severity of the issue
Definition Issue.hpp:110
const system_clock::time_point & ptime() const
original time point of the issue
Definition Issue.hpp:131
const std::string & message() const
General cause of the issue.
Definition Issue.hpp:104
const Issue * cause() const
return the cause Issue of this Issue
Definition Issue.hpp:100
virtual void write(const Issue &issue)=0
OutputStream & chained()
std::string to_string(severity s)
@ Debug
Definition Severity.hpp:38
@ Error
Definition Severity.hpp:42
@ Fatal
Definition Severity.hpp:43
@ Log
Definition Severity.hpp:39
@ Warning
Definition Severity.hpp:41
@ Information
Definition Severity.hpp:40
#define TRACE_NAME
enum severity type
Definition Severity.hpp:57

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