LCOV - code coverage report
Current view: top level - ers/pybindsrc - module.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 60 0
Test Date: 2025-12-21 13:07:08 Functions: 0.0 % 2 0

            Line data    Source code
       1              : #include "ers/AnyIssue.hpp"
       2              : #include "ers/Issue.hpp"
       3              : #include "ers/IssueFactory.hpp"
       4              : #include "ers/Context.hpp"
       5              : #include "ers/LocalContext.hpp"
       6              : #include "ers/RemoteContext.hpp"
       7              : #include "ers/Severity.hpp"
       8              : #include "ers/ers.hpp"
       9              : #include "ers/OutputStream.hpp"
      10              : 
      11              : #include <exception>
      12              : #include <pybind11/pybind11.h>
      13              : #include <pybind11/stl.h>
      14              : 
      15              : namespace py = pybind11;
      16              : 
      17              : 
      18            0 : PYBIND11_MODULE(_daq_ers_py, module) {
      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            0 :   py::class_<std::exception>(module, "STDException");
      27              :   
      28            0 :   py::class_<ers::Issue, std::exception>(module, "Issue");
      29              : 
      30            0 :   py::class_<ers::OutputStream>(module, "OutputStream");
      31              :   
      32              :   // Concrete Issue class 
      33            0 :   py::class_<ers::AnyIssue, ers::Issue>(module, "AnyIssue")
      34              :    // constructor 1
      35            0 :    .def(py::init<const std::string &, const ers::Context &, 
      36            0 :         const std::string &>())
      37              :    // constructor 2
      38            0 :    .def(py::init<const std::string &,
      39              :         const ers::inheritance_type &,
      40              :         ers::Severity, const ers::Context &,
      41              :         const system_clock::time_point &,const std::string &,
      42              :         const std::vector<std::string> &, const std::map<std::string,
      43            0 :         std::string> &, const ers::Issue *>())    
      44            0 :    .def("get_class_name", &ers::AnyIssue::get_class_name)
      45            0 :    .def("get_class_inheritance", &ers::AnyIssue::get_class_inheritance)    
      46            0 :    .def("raise", &ers::AnyIssue::raise)
      47            0 :    .def("what", &ers::AnyIssue::what)
      48            0 :    .def("cause", &ers::AnyIssue::cause)
      49            0 :    .def("severity", &ers::AnyIssue::severity)
      50            0 :    .def("qualifiers",&ers::AnyIssue::qualifiers)
      51            0 :    .def("parameters", &ers::AnyIssue::parameters);
      52              : 
      53              :   // Bindings for Context base class and derived classes
      54              : 
      55            0 :   py::class_<ers::Context>(module, "Context")
      56            0 :     .def("cwd", &ers::Context::cwd)
      57            0 :     .def("function_name", &ers::Context::function_name)
      58            0 :     .def("file_name", &ers::Context::file_name)
      59            0 :     .def("host_name", &ers::Context::host_name)
      60            0 :     .def("package_name", &ers::Context::package_name)
      61            0 :     .def("user_name", &ers::Context::user_name)
      62            0 :     .def("application_name", &ers::Context::application_name)
      63            0 :     .def("user_id", &ers::Context::user_id)
      64            0 :     .def("user_name", &ers::Context::user_name)
      65            0 :     .def("stack_size", &ers::Context::stack_size)
      66            0 :     .def("stack_symbols", &ers::Context::stack_symbols)
      67            0 :     .def("line_number", &ers::Context::line_number)
      68            0 :     .def("process_id", &ers::Context::process_id)
      69            0 :     .def("thread_id", &ers::Context::thread_id);
      70              : 
      71              :   // And now some concrete classes deriving from Context
      72            0 :   py::class_<ers::LocalContext, ers::Context>(module, "LocalContext")
      73            0 :     .def(py::init<const char *, const char *, int, const char *, bool>());
      74              :   
      75            0 :   py::class_<ers::RemoteProcessContext>(module, "RemoteProcessContext")
      76            0 :     .def(py::init<const std::string &, int, int, const std::string &, int, const std::string &, const std::string &>());
      77              : 
      78            0 :   py::class_<ers::RemoteContext, ers::Context>(module, "RemoteContext")
      79            0 :     .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            0 :   py::class_<ers::Severity>(module,"Severity")
      83            0 :     .def(py::init<ers::severity &, int &>())
      84            0 :     .def_readwrite("type", &ers::Severity::type)
      85            0 :     .def_readwrite("rank", &ers::Severity::rank);
      86            0 :   py::enum_<ers::severity>(module,"severity")
      87            0 :     .value("Debug",ers::severity::Debug)
      88            0 :     .value("Log",ers::severity::Log)
      89            0 :     .value("Information",ers::severity::Information)
      90            0 :     .value("Warning",ers::severity::Warning)
      91            0 :     .value("Error",ers::severity::Error)
      92            0 :     .value("Fatal",ers::severity::Fatal)
      93            0 :     .export_values();
      94              : 
      95              :   // Bind the various logging calls
      96            0 :   module.def("debug", &ers::debug, "sends issue to the debug stream", py::arg("issue"), py::arg("level") );
      97            0 :   module.def("log", &ers::log, "sends issue to the log stream", py::arg("issue"));
      98            0 :   module.def("info", &ers::info, "sends issue to the information stream", py::arg("issue"));
      99            0 :   module.def("warning", &ers::warning,  "sends issue to the warning stream", py::arg("issue"));
     100            0 :   module.def("error", &ers::error, "sends issue to the error stream", py::arg("issue"));
     101            0 :   module.def("fatal", &ers::fatal, "sends issue to the fatal stream", py::arg("issue"));
     102            0 :   module.def("debug_level", &ers::debug_level, "returns current debug level for ERS");
     103            0 :   module.def("verbosity_level", &ers::verbosity_level, "returns current verbosity level for ERS");
     104            0 :   module.def("enable_core_dump", &ers::enable_core_dump, "does what the name implies");
     105            0 : }
        

Generated by: LCOV version 2.0-1