μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
enums_logging.cpp
Go to the documentation of this file.
1
3
4
5#include "pybind11/pybind11.h"
6
8#include "uhal/log/log.hpp"
10
11
12namespace py = pybind11;
13
14
16{
17 switch ( logLevel )
18 {
19 case pycohal::DEBUG :
21 break;
22 case pycohal::INFO :
24 break;
25 case pycohal::NOTICE :
27 break;
28 case pycohal::WARNING :
30 break;
31 case pycohal::ERROR :
33 break;
34 case pycohal::FATAL :
36 break;
37 default :
38 throw pycohal::PycohalLogLevelEnumError();
39 }
40}
41
42
43const bool& pycohal::LoggingIncludes ( const pycohal::LogLevel& logLevel )
44{
45 switch ( logLevel )
46 {
47 case pycohal::DEBUG :
49 case pycohal::INFO :
51 case pycohal::NOTICE :
53 case pycohal::WARNING :
55 case pycohal::ERROR :
57 case pycohal::FATAL :
59 default :
60 throw PycohalLogLevelEnumError();
61 }
62}
63
64
65void pycohal::wrap_enums(pybind11::module_& aModule)
66{
67 py::enum_<uhal::defs::NodePermission> ( aModule, "NodePermission" )
68 .value ( "READ", uhal::defs::READ )
69 .value ( "WRITE", uhal::defs::WRITE )
70 .value ( "READWRITE", uhal::defs::READWRITE )
71 ;
72 py::enum_<uhal::defs::BlockReadWriteMode> ( aModule, "BlockReadWriteMode" )
73 .value ( "SINGLE", uhal::defs::SINGLE )
74 .value ( "INCREMENTAL", uhal::defs::INCREMENTAL )
75 .value ( "NON_INCREMENTAL", uhal::defs::NON_INCREMENTAL )
76 .value ( "HIERARCHICAL", uhal::defs::HIERARCHICAL )
77 ;
78 py::enum_<pycohal::LogLevel> ( aModule, "LogLevel" )
79 .value ( "FATAL", pycohal::FATAL )
80 .value ( "ERROR", pycohal::ERROR )
81 .value ( "WARNING", pycohal::WARNING )
82 .value ( "NOTICE", pycohal::NOTICE )
83 .value ( "INFO", pycohal::INFO )
84 .value ( "DEBUG", pycohal::DEBUG )
85 ;
86}
87
88void pycohal::wrap_logging_functions(pybind11::module_& aModule)
89{
90 aModule.def ( "setLogLevelFromEnvironment", uhal::setLogLevelFromEnvironment );
91 aModule.def ( "disableLogging", uhal::disableLogging );
92 aModule.def ( "setLogLevelTo", pycohal::setLogLevelTo );
93 aModule.def ( "LoggingIncludes", pycohal::LoggingIncludes, py::return_value_policy::copy );
94}
95
96
void wrap_enums(pybind11::module_ &)
void setLogLevelTo(const pycohal::LogLevel &logLevel)
Wrapper function for uhal::setLogLevelTo - converts pycohal::LogLevel enum values to C++ uhal log-lev...
void wrap_logging_functions(pybind11::module_ &)
LogLevel
Log level enum - switch to using enums for setting log-levels in python.
const bool & LoggingIncludes(const pycohal::LogLevel &logLevel)
Wrapper function for uhal::LoggingIncludes - converts pycohal::LogLevel enum values to C++ uhal log-l...
DebugLevel Debug
Definition: LogLevels.cpp:133
void setLogLevelTo(const FatalLevel &)
Function to specify, at runtime, that only messages with a severity level above Fatal should be logge...
Definition: log.cpp:87
const bool & LoggingIncludes(const FatalLevel &)
Function to check at runtime whether the level Fatal is to be included in the log output.
Definition: log.cpp:99
ErrorLevel Error
Definition: LogLevels.cpp:61
void disableLogging()
Function to disable all logging levels.
Definition: log.cpp:64
FatalLevel Fatal
Definition: LogLevels.cpp:43
WarningLevel Warning
Definition: LogLevels.cpp:79
InfoLevel Info
Definition: LogLevels.cpp:115
NoticeLevel Notice
Definition: LogLevels.cpp:97
void setLogLevelFromEnvironment(const char *aEnvVar)
Function to specify that the logging level should be retrieved from an environment variable.
Definition: log.cpp:16