23 #include "pybind11/pybind11.h"
27 namespace py = pybind11;
44 auto state = PyGILState_Ensure();
45 PyObject_CallObject(_callable,
nullptr);
46 PyGILState_Release(state);
54 py::module mod(
"log");
56 py::class_<Log> cls(mod,
"Log");
59 cls.def(py::init<>());
62 cls.attr(
"TRACE") = py::int_(5000);
63 cls.attr(
"DEBUG") = py::int_(10000);
64 cls.attr(
"INFO") = py::int_(20000);
65 cls.attr(
"WARN") = py::int_(30000);
66 cls.attr(
"ERROR") = py::int_(40000);
67 cls.attr(
"FATAL") = py::int_(50000);
79 cls.def(
"logMsg", [](
Log&
log,
int level, std::string
const& filename, std::string
const& funcname,
80 unsigned int lineno, std::string
const& msg) {
81 log.
logMsg(log4cxx::Level::toLevel(level),
82 log4cxx::spi::LocationInfo(filename.c_str(), funcname.c_str(), lineno), msg.c_str());
89 cls.def_static(
"configure", (
void (*)(std::string
const&))
Log::configure);
92 cls.def_static(
"getLogger", (
Log(*)(std::string
const&))Log::getLogger);
97 cls.def_static(
"MDCRegisterInit", [](py::function func) {
98 auto handle = func.release();
static Log getDefaultLogger()
Return default logger instance, same as default constructor.
bool isDebugEnabled() const
Check whether the logger is enabled for the DEBUG Level.
static void configure()
Explicitly configures log4cxx and initializes logging system.
static std::string getDefaultLoggerName()
Get the current default logger name.
void logMsg(log4cxx::LevelPtr level, log4cxx::spi::LocationInfo const &location, std::string const &msg)
Method used by LOGS_INFO and similar macros to process a log message.
callable_wrapper(PyObject *callable)
bool isFatalEnabled() const
Check whether the logger is enabled for the FATAL Level.
This static class includes a variety of methods for interacting with the the logging module...
bool isEnabledFor(int level) const
Return whether the logging threshold of the logger is less than or equal to LEVEL.
bool isErrorEnabled() const
Check whether the logger is enabled for the ERROR Level.
static void MDC(std::string const &key, std::string const &value)
Places a KEY/VALUE pair in the Mapped Diagnostic Context (MDC) for the current thread.
LSST DM logging module built on log4cxx.
static void MDCRemove(std::string const &key)
Remove the value associated with KEY within the MDC.
bool isTraceEnabled() const
Check whether the logger is enabled for the TRACE Level.
int getLevel() const
Retrieve the logging threshold.
void setLevel(int level)
Set the logging threshold to LEVEL.
bool isWarnEnabled() const
Check whether the logger is enabled for the WARN Level.
static Log getLogger(Log const &logger)
unsigned lwpID()
Function which returns LWP ID on platforms which support it.
std::string getName() const
Get the logger name associated with the Log object.
static void configure_prop(std::string const &properties)
Configures log4cxx using a string containing the list of properties, equivalent to configuring from a...
bool isInfoEnabled() const
Check whether the logger is enabled for the INFO Level.
static void popContext()
Pops the last pushed name off the global hierarchical default logger name.
static void pushContext(std::string const &name)
Pushes NAME onto the global hierarchical default logger name.
static int MDCRegisterInit(std::function< void()> function)