ATLAS Offline Software
Loading...
Searching...
No Matches
PyLogger.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
10
11
12#include "RootUtils/PyLogger.h"
13#include "Utility.h"
14
15
16namespace RootUtils {
17
18
28 : m_debugfn (debugfn),
29 m_errorfn (errorfn)
30{
31 Py_INCREF (debugfn);
32 Py_INCREF (errorfn);
33}
34
35
40{
41 Py_DECREF (m_debugfn);
42 Py_DECREF (m_errorfn);
43}
44
45
50void PyLogger::debug (const char* msg)
51{
53}
54
55
60void PyLogger::error (const char* msg)
61{
63}
64
65
73void PyLogger::call (PyObject* fn, const char* msg)
74{
75 if (!fn || fn == Py_None)
76 return;
77
78 PyObject* res = PyObject_CallFunction (fn, (char*)"s", msg);
79 if (res == 0)
81 Py_DECREF (res);
82}
83
84
85} // namespace RootUtils
_object PyObject
std::pair< std::vector< unsigned int >, bool > res
A concrete implementation of ILogger that calls back to Python.
Utility code originally from pyroot.
virtual void debug(const char *msg)
Log a debugging message.
Definition PyLogger.cxx:50
~PyLogger()
Destructor.
Definition PyLogger.cxx:39
PyObject * m_errorfn
The error message function.
Definition PyLogger.h:83
PyLogger(PyObject *debugfn, PyObject *errorfn)
Constructor.
Definition PyLogger.cxx:27
static void call(PyObject *fn, const char *msg)
Common code to call Python callback.
Definition PyLogger.cxx:73
PyObject * m_debugfn
The debug message function.
Definition PyLogger.h:80
virtual void error(const char *msg)
Log an error message.
Definition PyLogger.cxx:60
CPyCppyy::PyException PyException
Definition Utility.h:24
MsgStream & msg
Definition testRead.cxx:32