DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Schema.cpp
Go to the documentation of this file.
1#include <ers/Schema.hpp>
2
3// converters with allocation
6{
7
9 to_schema(c, out);
10 return out;
11}
12
15{
16
18 to_schema(i, out);
19 return out;
20}
21
24{
25
27 to_schema(i, out);
28 return out;
29}
30
31void
33{
34
35 out.set_cwd(c.cwd());
36 out.set_file_name(c.file_name());
37 out.set_function_name(c.function_name());
38 out.set_host_name(c.host_name());
39 out.set_line_number(c.line_number());
40 out.set_package_name(c.package_name());
41
42 out.set_process_id(c.process_id());
43 out.set_thread_id(c.thread_id());
44 out.set_user_id(c.user_id());
45 out.set_user_name(c.user_name());
46 out.set_application_name(c.application_name());
47}
48
49void
51{
52
53 auto c = to_schema(i.context());
54
55 (*out.mutable_context()) = c;
56
57 out.set_name(i.get_class_name());
58
59 auto inheritance = i.get_class_inheritance();
60 for (auto& c : inheritance) {
61 out.add_inheritance(c);
62 }
63
64 out.set_message(i.message());
65 out.set_severity(ers::to_string(i.severity()));
66 auto time = std::chrono::duration_cast<std::chrono::nanoseconds>(i.ptime().time_since_epoch()).count();
67 out.set_time(time);
68
69 auto& params = (*out.mutable_parameters());
70 for (auto p : i.parameters()) {
71 params[p.first] = p.second;
72 }
73}
74
75void
77{
78
79 (*out.mutable_final()) = to_schema(i);
80
81 auto cause_ptr = i.cause();
82
83 while (cause_ptr) {
84 auto ptr = out.add_causes();
85 to_schema(*cause_ptr, *ptr);
86 ptr->set_severity(ers::to_string(i.severity())); // severity is forced to be the same as the top issue
87 cause_ptr = cause_ptr->cause();
88 }
89}
An abstract interface to access an Issue context.
Definition Context.hpp:40
Base class for any user define issue.
Definition Issue.hpp:76
const Context & context() const
Context of the issue.
Definition Issue.hpp:102
ers::Severity severity() const
severity of the issue
Definition Issue.hpp:110
virtual const char * get_class_name() const =0
Get key for class (used for serialisation).
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 string_map & parameters() const
return array of parameters
Definition Issue.hpp:108
virtual inheritance_type get_class_inheritance() const =0
Get inheritance chain.
const Issue * cause() const
return the cause Issue of this Issue
Definition Issue.hpp:100
dunedaq::ersschema::IssueChain to_schema_chain(const Issue &i)
Definition Schema.cpp:23
std::string to_string(severity s)
dunedaq::ersschema::Context to_schema(const Context &c)
Definition Schema.cpp:5