Belle II Software development
LogPythonInterface.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <framework/logging/LogConfig.h>
12
13#include <boost/python/dict.hpp>
14
15#include <string>
16
17namespace Belle2 {
22
45 public:
48
55
62
68 void setDebugLevel(int level);
69
76 void setLogInfo(LogConfig::ELogLevel level, int info);
77
84 void setPackageLogConfig(const std::string& package, const LogConfig& config);
85
91 void setMaxMessageRepetitions(unsigned repetitions);
92
99
106
112 int getDebugLevel();
113
121
128 LogConfig& getPackageLogConfig(const std::string& package);
129
136 LogConfig& getModuleLogConfig(const std::string& module);
137
143 unsigned getMaxMessageRepetitions() const;
144
151 void addLogFile(const std::string& filename, bool append = false);
152
156 void addLogConsole();
157
164 void addLogJSON(bool complete);
165
166
172 void addLogUDP(const std::string& hostname, unsigned short port);
173
179 void addLogConsole(bool color);
180
184 void reset();
185
189 void zeroCounters();
190
192 void enableErrorSummary(bool on);
193
197 void setPythonLoggingEnabled(bool enabled) const;
198
202 bool getPythonLoggingEnabled() const;
203
207 void setEscapeNewlinesEnabled(bool enabled) const;
208
212 bool getEscapeNewlinesEnabled() const;
213
220 static boost::python::object logDebug(boost::python::tuple args, const boost::python::dict& kwargs);
227 static boost::python::object logInfo(boost::python::tuple args, const boost::python::dict& kwargs);
228
235 static boost::python::object logResult(boost::python::tuple args, const boost::python::dict& kwargs);
242 static boost::python::object logWarning(boost::python::tuple args, const boost::python::dict& kwargs);
249 static boost::python::object logError(boost::python::tuple args, const boost::python::dict& kwargs);
250
257 static boost::python::object logFatal(boost::python::tuple args, const boost::python::dict& kwargs);
258
260 boost::python::dict getLogStatistics();
262 static void exposePythonAPI();
263 protected:
264 };
265
267} // end namespace Belle2
The LogConfig class.
Definition LogConfig.h:22
ELogLevel
Definition of the supported log levels.
Definition LogConfig.h:26
bool getEscapeNewlinesEnabled() const
Get flag if newlines in log messages to console should be replaced by ' '`.
void setDebugLevel(int level)
Set the debug messaging level.
void setAbortLevel(LogConfig::ELogLevel level)
Set the abort log level.
static boost::python::object logFatal(boost::python::tuple args, const boost::python::dict &kwargs)
Produce fatal message.
int getLogInfo(LogConfig::ELogLevel level)
Get the printed log information for the given level.
boost::python::dict getLogStatistics()
return dict with log statistics
void setPackageLogConfig(const std::string &package, const LogConfig &config)
Set LogConfig for a given package.
void addLogFile(const std::string &filename, bool append=false)
Add a file as output connection.
void setPythonLoggingEnabled(bool enabled) const
Set flag if logging should be done via python sys.stdout
LogConfig::ELogLevel getAbortLevel()
Get the abort level.
static boost::python::object logWarning(boost::python::tuple args, const boost::python::dict &kwargs)
Produce warning message.
static void exposePythonAPI()
expose python API
bool getPythonLoggingEnabled() const
Get flag if logging should be done via python sys.stdout
LogConfig & getModuleLogConfig(const std::string &module)
Get the LogConfig for the given module.
void enableErrorSummary(bool on)
Enable/Disable error summary.
void setMaxMessageRepetitions(unsigned repetitions)
Set maximum number of repetitions before silencing "identical" log messages.
static boost::python::object logDebug(boost::python::tuple args, const boost::python::dict &kwargs)
Produce debug message.
void addLogConsole()
Add the console as output connection.
void addLogUDP(const std::string &hostname, unsigned short port)
Add a UDP server as an output connection.
void setLogLevel(LogConfig::ELogLevel level)
Set the log level.
int getDebugLevel()
Get the debug level.
void reset()
Reset logging connections.
static boost::python::object logInfo(boost::python::tuple args, const boost::python::dict &kwargs)
Produce info message.
void addLogJSON(bool complete)
Add the console as output connection but print the log messages as json objects so that they can be p...
void setLogInfo(LogConfig::ELogLevel level, int info)
Set the printed log information for the given level.
unsigned getMaxMessageRepetitions() const
Get maximum number of repetitions before silencing "identical" log messages.
void setEscapeNewlinesEnabled(bool enabled) const
Set flag if newlines in log messages to console should be replaced by ' '.
LogConfig & getPackageLogConfig(const std::string &package)
Get the LogConfig for the given package.
void zeroCounters()
Reset logging counters.
static boost::python::object logError(boost::python::tuple args, const boost::python::dict &kwargs)
Produce error message.
static boost::python::object logResult(boost::python::tuple args, const boost::python::dict &kwargs)
Produce result message.
LogConfig::ELogLevel getLogLevel()
Get the log level.
Abstract base class for different kinds of events.