![]() |
Belle II Software
release-08-02-04
|
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. More... | |
| void | setAbortLevel (LogConfig::ELogLevel level) |
| Set the abort log level. More... | |
| void | setDebugLevel (int level) |
| Set the debug messaging level. More... | |
| void | setLogInfo (LogConfig::ELogLevel level, int info) |
| Set the printed log information for the given level. More... | |
| void | setPackageLogConfig (const std::string &package, const LogConfig &config) |
| Set LogConfig for a given package. More... | |
| void | setMaxMessageRepetitions (unsigned repetitions) |
| Set maximum number of repetitions before silencing "identical" log messages. More... | |
| LogConfig::ELogLevel | getLogLevel () |
| Get the log level. More... | |
| LogConfig::ELogLevel | getAbortLevel () |
| Get the abort level. More... | |
| int | getDebugLevel () |
| Get the debug level. More... | |
| int | getLogInfo (LogConfig::ELogLevel level) |
| Get the printed log information for the given level. More... | |
| LogConfig & | getPackageLogConfig (const std::string &package) |
| Get the LogConfig for the given package. More... | |
| unsigned | getMaxMessageRepetitions () const |
| Get maximum number of repetitions before silencing "identical" log messages. More... | |
| void | addLogFile (const std::string &filename, bool append=false) |
| Add a file as output connection. More... | |
| void | addLogConsole () |
| Add the console as output connection. More... | |
| 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. More... | |
| void | addLogUDP (const std::string &hostname, unsigned short port) |
| Add a UDP server as an output connection. More... | |
| void | addLogConsole (bool color) |
| Add the console as output connection. More... | |
| 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 More... | |
Static Public Member Functions | |
| static boost::python::object | logDebug (boost::python::tuple args, const boost::python::dict &kwargs) |
| Produce debug message. More... | |
| static boost::python::object | logInfo (boost::python::tuple args, const boost::python::dict &kwargs) |
| Produce info message. More... | |
| static boost::python::object | logResult (boost::python::tuple args, const boost::python::dict &kwargs) |
| Produce result message. More... | |
| static boost::python::object | logWarning (boost::python::tuple args, const boost::python::dict &kwargs) |
| Produce warning message. More... | |
| static boost::python::object | logError (boost::python::tuple args, const boost::python::dict &kwargs) |
| Produce error message. More... | |
| static boost::python::object | logFatal (boost::python::tuple args, const boost::python::dict &kwargs) |
| Produce fatal message. More... | |
| static void | exposePythonAPI () |
| expose python API More... | |
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.
| 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.
|
static |
| LogConfig::ELogLevel getAbortLevel | ( | ) |
| int getDebugLevel | ( | ) |
| 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.
|
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 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 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.