BewareMyPower commented on pull request #7932:
URL: https://github.com/apache/pulsar/pull/7932#issuecomment-683580112


   You're right, the internal field of logger should be not a `fstream` but a 
`vector<string>`. Here I use the file because if other tests were affected by 
the custom logger, I could check the failure logs with a file.
   
   The reason why the custom logger affects other tests is that the 
`ClientConfiguration`'s logger factory is not associated with a `Client`, it 
only changes a `static` factory, see `LogUtils.cc`:
   
   ```c++
   static std::atomic<LoggerFactory*> s_loggerFactory(nullptr);  // 
setLoggerFactory changes it
   ```
   
   And each compile unit includes `LogUtils.h` to use a thread local logger:
   
   ```c++
   #define DECLARE_LOG_OBJECT()                                                 
                    \
       static pulsar::Logger* logger() {                                        
                    \
           static thread_local std::unique_ptr<pulsar::Logger> 
threadSpecificLogPtr;                \
           pulsar::Logger* ptr = threadSpecificLogPtr.get();                    
                    \
           if (PULSAR_UNLIKELY(!ptr)) {                                         
                    \
               std::string logger = pulsar::LogUtils::getLoggerName(__FILE__);  
                    \
               
threadSpecificLogPtr.reset(pulsar::LogUtils::getLoggerFactory()->getLogger(logger));
 \
               ptr = threadSpecificLogPtr.get();                                
                    \
           }                                                                    
                    \
           return ptr;                                                          
                    \
       }
   ```


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


Reply via email to