Belle II Software light-2406-ragdoll
|
Thin wrapper to expose a usable interface to the logging framework in python. More...
#include <LogPythonInterface.h>
Public Member Functions | |
LogPythonInterface () | |
ctor | |
void | setLogLevel (LogConfig::ELogLevel level) |
Set the log level. | |
void | setAbortLevel (LogConfig::ELogLevel level) |
Set the abort log level. | |
void | setDebugLevel (int level) |
Set the debug messaging level. | |
void | setLogInfo (LogConfig::ELogLevel level, int info) |
Set the printed log information for the given level. | |
void | setPackageLogConfig (const std::string &package, const LogConfig &config) |
Set LogConfig for a given package. | |
void | setMaxMessageRepetitions (unsigned repetitions) |
Set maximum number of repetitions before silencing "identical" log messages. | |
LogConfig::ELogLevel | getLogLevel () |
Get the log level. | |
LogConfig::ELogLevel | getAbortLevel () |
Get the abort level. | |
int | getDebugLevel () |
Get the debug level. | |
int | getLogInfo (LogConfig::ELogLevel level) |
Get the printed log information for the given level. | |
LogConfig & | getPackageLogConfig (const std::string &package) |
Get the LogConfig for the given package. | |
unsigned | getMaxMessageRepetitions () const |
Get maximum number of repetitions before silencing "identical" log messages. | |
void | addLogFile (const std::string &filename, bool append=false) |
Add a file as output connection. | |
void | addLogConsole () |
Add the console as output connection. | |
void | addLogJSON (bool complete) |
Add the console as output connection but print the log messages as json objects so that they can be parsed easily. | |
void | addLogUDP (const std::string &hostname, unsigned short port) |
Add a UDP server as an output connection. | |
void | addLogConsole (bool color) |
Add the console as output connection. | |
void | reset () |
Reset logging connections. | |
void | zeroCounters () |
Reset logging counters. | |
void | enableErrorSummary (bool on) |
Enable/Disable error summary. | |
void | setPythonLoggingEnabled (bool enabled) const |
Set flag if logging should be done via python sys.stdout | |
bool | getPythonLoggingEnabled () const |
Get flag if logging should be done via python sys.stdout | |
void | setEscapeNewlinesEnabled (bool enabled) const |
Set flag if newlines in log messages to console should be replaced by ' '. | |
bool | getEscapeNewlinesEnabled () const |
Get flag if newlines in log messages to console should be replaced by ' '`. | |
boost::python::dict | getLogStatistics () |
return dict with log statistics | |
Static Public Member Functions | |
static boost::python::object | logDebug (boost::python::tuple args, const boost::python::dict &kwargs) |
Produce debug message. | |
static boost::python::object | logInfo (boost::python::tuple args, const boost::python::dict &kwargs) |
Produce info message. | |
static boost::python::object | logResult (boost::python::tuple args, const boost::python::dict &kwargs) |
Produce result message. | |
static boost::python::object | logWarning (boost::python::tuple args, const boost::python::dict &kwargs) |
Produce warning message. | |
static boost::python::object | logError (boost::python::tuple args, const boost::python::dict &kwargs) |
Produce error message. | |
static boost::python::object | logFatal (boost::python::tuple args, const boost::python::dict &kwargs) |
Produce fatal message. | |
static void | exposePythonAPI () |
expose python API | |
Thin wrapper to expose a usable interface to the logging framework in python.
This class exposes a object called "logging" to the python interface. With this object it is possible to set all properties of the logging system directly in the steering file in a consistent manner This class also exposes the LogConfig class as well as the LogConfig::ELogLevel and LogConfig::ELogInfo enums to make setting of properties more transparent by using the names and not just the values. To set or get the log level, one can simply do:
logging.log_level = LogLevel.FATAL print "Logging level set to", logging.log_level
This module also allows to send log messages directly from python to ease consistent error reporting througout the framework
B2WARNING("This is a warning message");
For all features, see b2logging.py in the framework/examples folder
Definition at line 44 of file LogPythonInterface.h.
|
inline |
void addLogConsole | ( | ) |
Add the console as output connection.
Color will be used automatically if supported
Definition at line 111 of file LogPythonInterface.cc.
void addLogConsole | ( | bool | color | ) |
Add the console as output connection.
color | Flag whether color should be used |
Definition at line 116 of file LogPythonInterface.cc.
void addLogFile | ( | const std::string & | filename, |
bool | append = false |
||
) |
Add a file as output connection.
filename | The text file name |
append | Flag whether output should be appended to an existing file |
Definition at line 106 of file LogPythonInterface.cc.
void addLogJSON | ( | bool | complete | ) |
Add the console as output connection but print the log messages as json objects so that they can be parsed easily.
complete | if true ignore the log info configuration and print all parts of the log message. |
Definition at line 96 of file LogPythonInterface.cc.
void addLogUDP | ( | const std::string & | hostname, |
unsigned short | port | ||
) |
Add a UDP server as an output connection.
hostname | the hostname of the UDP server. Will throw an exception if it can not be resolved. |
port | the port to connect to |
Definition at line 101 of file LogPythonInterface.cc.
void enableErrorSummary | ( | bool | on | ) |
Enable/Disable error summary.
Definition at line 131 of file LogPythonInterface.cc.
|
static |
expose python API
Expose python api.
Definition at line 188 of file LogPythonInterface.cc.
LogConfig::ELogLevel getAbortLevel | ( | ) |
Get the abort level.
Definition at line 71 of file LogPythonInterface.cc.
int getDebugLevel | ( | ) |
bool getEscapeNewlinesEnabled | ( | ) | const |
Get flag if newlines in log messages to console should be replaced by '
'`.
Definition at line 151 of file LogPythonInterface.cc.
int getLogInfo | ( | LogConfig::ELogLevel | level | ) |
Get the printed log information for the given level.
level | The log level |
Definition at line 81 of file LogPythonInterface.cc.
LogConfig::ELogLevel getLogLevel | ( | ) |
dict getLogStatistics | ( | ) |
return dict with log statistics
Return dict containing message counters.
Definition at line 157 of file LogPythonInterface.cc.
unsigned getMaxMessageRepetitions | ( | ) | const |
Get maximum number of repetitions before silencing "identical" log messages.
Identity only checks for log level and message content (excluding variables)
Definition at line 91 of file LogPythonInterface.cc.
LogConfig & getPackageLogConfig | ( | const std::string & | package | ) |
Get the LogConfig for the given package.
package | The package name |
Definition at line 86 of file LogPythonInterface.cc.
bool getPythonLoggingEnabled | ( | ) | const |
Get flag if logging should be done via python sys.stdout
Definition at line 141 of file LogPythonInterface.cc.
|
static |
Produce debug message.
args | positional arguments, concatenated to form message |
kwargs | keyword arguments to be converted to log variables |
Definition at line 577 of file LogPythonInterface.cc.
|
static |
Produce error message.
args | positional arguments, concatenated to form message |
kwargs | keyword arguments to be converted to log variables |
Definition at line 609 of file LogPythonInterface.cc.
|
static |
Produce fatal message.
args | positional arguments, concatenated to form message |
kwargs | keyword arguments to be converted to log variables |
Definition at line 615 of file LogPythonInterface.cc.
|
static |
Produce info message.
args | positional arguments, concatenated to form message |
kwargs | keyword arguments to be converted to log variables |
Definition at line 585 of file LogPythonInterface.cc.
|
static |
Produce result message.
args | positional arguments, concatenated to form message |
kwargs | keyword arguments to be converted to log variables |
Definition at line 593 of file LogPythonInterface.cc.
|
static |
Produce warning message.
args | positional arguments, concatenated to form message |
kwargs | keyword arguments to be converted to log variables |
Definition at line 601 of file LogPythonInterface.cc.
void reset | ( | ) |
Reset logging connections.
Definition at line 121 of file LogPythonInterface.cc.
void setAbortLevel | ( | LogConfig::ELogLevel | level | ) |
Set the abort log level.
level | The abort log level |
Definition at line 41 of file LogPythonInterface.cc.
void setDebugLevel | ( | int | level | ) |
Set the debug messaging level.
level | The debug level |
Definition at line 46 of file LogPythonInterface.cc.
void setEscapeNewlinesEnabled | ( | bool | enabled | ) | const |
Set flag if newlines in log messages to console should be replaced by '
'.
Definition at line 146 of file LogPythonInterface.cc.
void setLogInfo | ( | LogConfig::ELogLevel | level, |
int | info | ||
) |
Set the printed log information for the given level.
level | The log level |
info | The log information that should be printed |
Definition at line 51 of file LogPythonInterface.cc.
void setLogLevel | ( | LogConfig::ELogLevel | level | ) |
Set the log level.
level | The log level |
Definition at line 32 of file LogPythonInterface.cc.
void setMaxMessageRepetitions | ( | unsigned | repetitions | ) |
Set maximum number of repetitions before silencing "identical" log messages.
Identity only checks for log level and message content (excluding variables)
Definition at line 61 of file LogPythonInterface.cc.
void setPackageLogConfig | ( | const std::string & | package, |
const LogConfig & | config | ||
) |
Set LogConfig for a given package.
package | The package name |
config | The log configuration object |
Definition at line 56 of file LogPythonInterface.cc.
void setPythonLoggingEnabled | ( | bool | enabled | ) | const |
Set flag if logging should be done via python sys.stdout
Definition at line 136 of file LogPythonInterface.cc.
void zeroCounters | ( | ) |
Reset logging counters.
Definition at line 126 of file LogPythonInterface.cc.