BewareMyPower commented on a change in pull request #10981:
URL: https://github.com/apache/pulsar/pull/10981#discussion_r656716009
##########
File path: pulsar-client-cpp/python/src/config.cc
##########
@@ -110,21 +112,29 @@ class LoggerWrapper: public Logger {
public:
- LoggerWrapper(const std::string &logger, PyObject* pyLogger) {
+ LoggerWrapper(const std::string &filename, PyObject* pyLogger) {
_pyLogger = pyLogger;
Py_XINCREF(_pyLogger);
+ fallbackLogger = (new ConsoleLoggerFactory())->getLogger(filename);
Review comment:
What I said about singleton is to create a global `ConsoleLoggerFactory`
object and reuse it, in C++ it can be implemented simply like:
```c++
inline ConsoleLoggerFactory& globalConsoleLoggerFactory() {
static ConsoleLoggerFactory factory; // the object exists during the
whole lifetime of the process
return factory;
}
```
Then you only need to call `globalConsoleLoggerFactory().getLogger("xxx")`
to create a logger from the factory.
But your fix is also OK, you create a `ConsoleLoggerFactory` and delete it
every time a `LoggerWrapper` object is constructed and destructed. Since the
logger created by it doesn't bind to the factory, your fix is also OK.
--
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]