massakam commented on code in PR #377:
URL: https://github.com/apache/pulsar-client-cpp/pull/377#discussion_r1436381675


##########
lib/LogUtils.cc:
##########
@@ -25,6 +25,7 @@
 
 namespace pulsar {
 
+static std::atomic<LoggerFactory*> s_defaultLoggerFactory(new 
ConsoleLoggerFactory());

Review Comment:
   Should I fix it like this?
   ```cpp
   static std::atomic<LoggerFactory*> s_defaultLoggerFactory(nullptr);
   
   LoggerFactory* LogUtils::getLoggerFactory() {
       if (s_loggerFactory.load() != nullptr) {
           return s_loggerFactory.load();
       } else {
           if (s_defaultLoggerFactory.load() == nullptr) {
               LoggerFactory* oldFactory = nullptr;
               LoggerFactory* newFactory = new ConsoleLoggerFactory();
               if (!s_defaultLoggerFactory.compare_exchange_strong(oldFactory, 
newFactory)) {
                   delete newFactory; // there's already a factory set
               }
           }
           return s_defaultLoggerFactory.load();
       }
   }
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to