DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
module.cpp File Reference
#include "ers/AnyIssue.hpp"
#include "ers/Context.hpp"
#include "ers/Issue.hpp"
#include "ers/IssueFactory.hpp"
#include "ers/LocalContext.hpp"
#include "ers/OutputStream.hpp"
#include "ers/RemoteContext.hpp"
#include "ers/Severity.hpp"
#include "ers/ers.hpp"
#include <exception>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
Include dependency graph for module.cpp:

Go to the source code of this file.

Functions

 PYBIND11_MODULE (_daq_ers_py, module)

Function Documentation

◆ PYBIND11_MODULE()

PYBIND11_MODULE ( _daq_ers_py ,
module  )

Definition at line 17 of file module.cpp.

18{
19
20 // Class inheritence to be included
21 // std::exception -> ers::Issue -> ers::AnyIssue
22 // Abstract classes (like ers::Issue) cannot be called with
23 // pybind11. Line below is only a decleration of ers::Issue.
24
25 py::class_<std::exception>(module, "STDException");
26
27 py::class_<ers::Issue, std::exception>(module, "Issue");
28
29 py::class_<ers::OutputStream>(module, "OutputStream");
30
31 // Concrete Issue class
32 py::class_<ers::AnyIssue, ers::Issue>(module, "AnyIssue")
33 // constructor 1
34 .def(py::init<const std::string&, const ers::Context&, const std::string&>())
35 // constructor 2
36 .def(py::init<const std::string&,
39 const ers::Context&,
40 const system_clock::time_point&,
41 const std::string&,
42 const std::vector<std::string>&,
43 const std::map<std::string, std::string>&,
44 const ers::Issue*>())
45 .def("get_class_name", &ers::AnyIssue::get_class_name)
46 .def("get_class_inheritance", &ers::AnyIssue::get_class_inheritance)
47 .def("raise", &ers::AnyIssue::raise)
48 .def("what", &ers::AnyIssue::what)
49 .def("cause", &ers::AnyIssue::cause)
50 .def("severity", &ers::AnyIssue::severity)
51 .def("qualifiers", &ers::AnyIssue::qualifiers)
52 .def("parameters", &ers::AnyIssue::parameters);
53
54 // Bindings for Context base class and derived classes
55
56 py::class_<ers::Context>(module, "Context")
57 .def("cwd", &ers::Context::cwd)
58 .def("function_name", &ers::Context::function_name)
59 .def("file_name", &ers::Context::file_name)
60 .def("host_name", &ers::Context::host_name)
61 .def("package_name", &ers::Context::package_name)
62 .def("user_name", &ers::Context::user_name)
63 .def("application_name", &ers::Context::application_name)
64 .def("user_id", &ers::Context::user_id)
65 .def("user_name", &ers::Context::user_name)
66 .def("stack_size", &ers::Context::stack_size)
67 .def("stack_symbols", &ers::Context::stack_symbols)
68 .def("line_number", &ers::Context::line_number)
69 .def("process_id", &ers::Context::process_id)
70 .def("thread_id", &ers::Context::thread_id);
71
72 // And now some concrete classes deriving from Context
73 py::class_<ers::LocalContext, ers::Context>(module, "LocalContext")
74 .def(py::init<const char*, const char*, int, const char*, bool>());
75
76 py::class_<ers::RemoteProcessContext>(module, "RemoteProcessContext")
77 .def(py::init<const std::string&, int, int, const std::string&, int, const std::string&, const std::string&>());
78
79 py::class_<ers::RemoteContext, ers::Context>(module, "RemoteContext")
80 .def(py::init<const std::string&, const std::string&, int, const std::string&, ers::RemoteProcessContext&>());
81
82 // Severity includes both a class and and enum.
83 py::class_<ers::Severity>(module, "Severity")
84 .def(py::init<ers::severity&, int&>())
85 .def_readwrite("type", &ers::Severity::type)
86 .def_readwrite("rank", &ers::Severity::rank);
87 py::enum_<ers::severity>(module, "severity")
88 .value("Debug", ers::severity::Debug)
89 .value("Log", ers::severity::Log)
90 .value("Information", ers::severity::Information)
91 .value("Warning", ers::severity::Warning)
92 .value("Error", ers::severity::Error)
93 .value("Fatal", ers::severity::Fatal)
94 .export_values();
95
96 // Bind the various logging calls
97 module.def("debug", &ers::debug, "sends issue to the debug stream", py::arg("issue"), py::arg("level"));
98 module.def("log", &ers::log, "sends issue to the log stream", py::arg("issue"));
99 module.def("info", &ers::info, "sends issue to the information stream", py::arg("issue"));
100 module.def("warning", &ers::warning, "sends issue to the warning stream", py::arg("issue"));
101 module.def("error", &ers::error, "sends issue to the error stream", py::arg("issue"));
102 module.def("fatal", &ers::fatal, "sends issue to the fatal stream", py::arg("issue"));
103 module.def("debug_level", &ers::debug_level, "returns current debug level for ERS");
104 module.def("verbosity_level", &ers::verbosity_level, "returns current verbosity level for ERS");
105 module.def("enable_core_dump", &ers::enable_core_dump, "does what the name implies");
106}
virtual inheritance_type get_class_inheritance() const final
Get inheritance chain.
Definition AnyIssue.hpp:66
virtual void raise() const
throws a copy of this issue preserving the real issue type
Definition AnyIssue.hpp:68
virtual const char * get_class_name() const
Get key for class (used for serialisation).
Definition AnyIssue.hpp:64
An abstract interface to access an Issue context.
Definition Context.hpp:40
virtual void *const * stack_symbols() const =0
virtual int line_number() const =0
virtual int stack_size() const =0
virtual const char * user_name() const =0
virtual int user_id() const =0
virtual pid_t thread_id() const =0
virtual const char * host_name() const =0
virtual pid_t process_id() const =0
virtual const char * package_name() const =0
virtual const char * application_name() const =0
virtual const char * file_name() const =0
virtual const char * cwd() const =0
virtual const char * function_name() const =0
Base class for any user define issue.
Definition Issue.hpp:76
ers::Severity severity() const
severity of the issue
Definition Issue.hpp:110
const std::vector< std::string > & qualifiers() const
return array of qualifiers
Definition Issue.hpp:106
const string_map & parameters() const
return array of parameters
Definition Issue.hpp:108
const char * what() const noexcept
General cause of the issue.
Definition Issue.hpp:133
const Issue * cause() const
return the cause Issue of this Issue
Definition Issue.hpp:100
std::list< std::string > inheritance_type
Definition Issue.hpp:54
@ 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
enum severity type
Definition Severity.hpp:57