You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/09/25 22:56:28 UTC

[GitHub] [pulsar] merlimat commented on a change in pull request #5279: Support for python native logging from python wrapper

merlimat commented on a change in pull request #5279: Support for python native logging from python wrapper
URL: https://github.com/apache/pulsar/pull/5279#discussion_r328373782
 
 

 ##########
 File path: pulsar-client-cpp/python/src/config.cc
 ##########
 @@ -18,6 +18,99 @@
  */
 #include "utils.h"
 
+class LoggerWrapper: public Logger {
+    std::string _logger;
+    PyObject* _pyLogger;
+
+public:
+
+    LoggerWrapper(const std::string &logger, PyObject* pyLogger) : _logger(logger) {
+        _pyLogger = pyLogger;
+        Py_XINCREF(_pyLogger);
+    }
+
+    LoggerWrapper(const LoggerWrapper& other) {
+        _pyLogger = other._pyLogger;
+        Py_XINCREF(_pyLogger);
+    }
+
+    LoggerWrapper& operator=(const LoggerWrapper& other) {
+        _pyLogger = other._pyLogger;
+        Py_XINCREF(_pyLogger);
+        return *this;
+    }
+
+    virtual ~LoggerWrapper() {
+        Py_XDECREF(_pyLogger);
+    }
+
+    bool isEnabled(Level level) {
 
 Review comment:
   It might be overkill to get back into Python each time to check the log level. This will be called many times (eg. for the debug statements). is the logging level supposed to be changed frequently at runtime? Could we cache it in c++ land and only check on python every 1sec or so?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services