pinkavaj commented on a change in pull request #7713:
URL: https://github.com/apache/pulsar/pull/7713#discussion_r562163882
##########
File path: pulsar-client-cpp/python/src/config.cc
##########
@@ -74,6 +74,107 @@ static ClientConfiguration&
ClientConfiguration_setAuthentication(ClientConfigur
return conf;
}
+class LoggerWrapper: public Logger {
+ std::string _logger;
+ PyObject* _pyLogger;
+ int _currentPythonLogLevel = _getLogLevelValue(Logger::LEVEL_INFO);
+
+ void _updateCurrentPythonLogLevel() {
+ PyGILState_STATE state = PyGILState_Ensure();
+
+ try {
+ _currentPythonLogLevel = py::call_method<int>(_pyLogger,
"getEffectiveLevel");
+ } catch (py::error_already_set e) {
+ PyErr_Print();
+ }
+
+ PyGILState_Release(state);
+ };
+
+ int _getLogLevelValue(Level level) {
+ return 10 + (level * 10);
+ }
+
+ public:
+
+ LoggerWrapper(const std::string &logger, PyObject* pyLogger) :
_logger(logger) {
+ _pyLogger = pyLogger;
+ Py_XINCREF(_pyLogger);
+
+ _updateCurrentPythonLogLevel();
+ }
+
+ 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) {
+ return _getLogLevelValue(level) >= _currentPythonLogLevel;
+ }
+
+ void log(Level level, int line, const std::string& message) {
Review comment:
Feel free to show example and you incentive to help with decission.
----------------------------------------------------------------
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:
[email protected]