DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
module.cpp File Reference
#include "ers/AnyIssue.hpp"
#include "ers/Issue.hpp"
#include "ers/IssueFactory.hpp"
#include "ers/Context.hpp"
#include "ers/LocalContext.hpp"
#include "ers/RemoteContext.hpp"
#include "ers/Severity.hpp"
#include "ers/ers.hpp"
#include "ers/OutputStream.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 18 of file module.cpp.

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