Skip to content

Commit

Permalink
[Issue 10161] Fix missing LoggerFactoryPtr type. (apache#10164)
Browse files Browse the repository at this point in the history
Fixes apache#10161.

### Motivation

With issue apache#7132 the LoggerFactoryPtr was removed in favour of relevant memory-safe(r) pointers.

This change forgot to also change the Log4Cxx implementation, fix this by returning (as with
the other LoggerFactory's) a std::unique_ptr<LoggerFactory>.
  • Loading branch information
astifter authored May 21, 2021
1 parent 2be05fb commit d700f8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions pulsar-client-cpp/lib/Log4CxxLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ namespace pulsar {

class PULSAR_PUBLIC Log4CxxLoggerFactory : public LoggerFactory {
public:
static LoggerFactoryPtr create();
static LoggerFactoryPtr create(const std::string& log4cxxConfFile);
static std::unique_ptr<LoggerFactory> create();
static std::unique_ptr<LoggerFactory> create(const std::string& log4cxxConfFile);

Logger* getLogger(const std::string& fileName);
};

} // namespace pulsar

#endif
8 changes: 4 additions & 4 deletions pulsar-client-cpp/lib/Log4cxxLogger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Log4CxxLogger : public Logger {
}
};

LoggerFactoryPtr Log4CxxLoggerFactory::create() {
std::unique_ptr<LoggerFactory> Log4CxxLoggerFactory::create() {
if (!LogManager::getLoggerRepository()->isConfigured()) {
LogManager::getLoggerRepository()->setConfigured(true);
LoggerPtr root = log4cxx::Logger::getRootLogger();
Expand All @@ -73,10 +73,10 @@ LoggerFactoryPtr Log4CxxLoggerFactory::create() {
root->addAppender(appender);
}

return LoggerFactoryPtr(new Log4CxxLoggerFactory());
return std::unique_ptr<LoggerFactory>(new Log4CxxLoggerFactory());
}

LoggerFactoryPtr Log4CxxLoggerFactory::create(const std::string &log4cxxConfFile) {
std::unique_ptr<LoggerFactory> Log4CxxLoggerFactory::create(const std::string &log4cxxConfFile) {
try {
log4cxx::PropertyConfigurator::configure(log4cxxConfFile);
} catch (const std::exception &e) {
Expand All @@ -87,7 +87,7 @@ LoggerFactoryPtr Log4CxxLoggerFactory::create(const std::string &log4cxxConfFile
<< std::endl;
}

return LoggerFactoryPtr(new Log4CxxLoggerFactory());
return std::unique_ptr<LoggerFactory>(new Log4CxxLoggerFactory());
}

Logger *Log4CxxLoggerFactory::getLogger(const std::string &fileName) { return new Log4CxxLogger(fileName); }
Expand Down

0 comments on commit d700f8d

Please sign in to comment.