Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove log4cxx dependency and its specified configuration #283

Merged
merged 2 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 1 addition & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ MESSAGE(STATUS "BUILD_TESTS: " ${BUILD_TESTS})
option(BUILD_PERF_TOOLS "Build Pulsar CLI perf producer/consumer" OFF)
MESSAGE(STATUS "BUILD_PERF_TOOLS: " ${BUILD_PERF_TOOLS})

option(USE_LOG4CXX "Build with Log4cxx support" OFF)
MESSAGE(STATUS "USE_LOG4CXX: " ${USE_LOG4CXX})

IF (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
ENDIF ()
Expand Down Expand Up @@ -118,13 +115,7 @@ endif()

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(LOG_CATEGORY_NAME $ENV{LOG_CATEGORY_NAME})

if (NOT LOG_CATEGORY_NAME)
set(LOG_CATEGORY_NAME "\"pulsar.\"")
endif(NOT LOG_CATEGORY_NAME)

add_definitions(-DLOG_CATEGORY_NAME=${LOG_CATEGORY_NAME} -DBUILDING_PULSAR -DBOOST_ALL_NO_LIB -DBOOST_ALLOW_DEPRECATED_HEADERS)
add_definitions(-DBUILDING_PULSAR -DBOOST_ALL_NO_LIB -DBOOST_ALLOW_DEPRECATED_HEADERS)

# For dependencies other than OpenSSL, dynamic libraries are forbidden to link when LINK_STATIC is ON
if (LINK_STATIC)
Expand Down Expand Up @@ -178,24 +169,6 @@ if (LINK_STATIC AND NOT VCPKG_TRIPLET)
find_library(LIB_SNAPPY NAMES libsnappy.a)
message(STATUS "LIB_SNAPPY: ${LIB_SNAPPY}")

if (USE_LOG4CXX)
if (LOG4CXX_USE_DYNAMIC_LIBS)
find_library(LOG4CXX_LIBRARY_PATH log4cxx)
else ()
find_library(LOG4CXX_LIBRARY_PATH NAMES liblog4cxx.a)

# Libraries needed by log4cxx to link statically with
find_library(APR_LIBRARY_PATH NAMES libapr-1 PATHS /usr/lib /usr/local/apr/lib /usr/local/opt/apr/libexec/lib/)
find_library(APR_UTIL_LIBRARY_PATH NAMES libaprutil-1 PATHS /usr/lib /usr/local/apr/lib /usr/local/opt/apr-util/libexec/lib/)
find_library(EXPAT_LIBRARY_PATH NAMES libexpat expat)
if (APPLE)
find_library(ICONV_LIBRARY_PATH NAMES libiconv iconv)
else ()
set(ICONV_LIBRARY_PATH )
endif (APPLE)
endif (LOG4CXX_USE_DYNAMIC_LIBS)
endif (USE_LOG4CXX)

if (MSVC)
add_definitions(-DCURL_STATICLIB)
endif()
Expand Down Expand Up @@ -241,11 +214,6 @@ else()
else ()
find_library(LIB_SNAPPY NAMES snappy libsnappy)
endif ()

if (USE_LOG4CXX)
find_library(LOG4CXX_LIBRARY_PATH log4cxx)
find_path(LOG4CXX_INCLUDE_PATH log4cxx/logger.h)
endif (USE_LOG4CXX)
endif ()

if (Boost_MAJOR_VERSION EQUAL 1 AND Boost_MINOR_VERSION LESS 69)
Expand Down Expand Up @@ -280,11 +248,6 @@ if (BUILD_TESTS)
find_path(GMOCK_INCLUDE_PATH gmock/gmock.h)
endif ()

if (USE_LOG4CXX)
set(CMAKE_CXX_FLAGS " -DUSE_LOG4CXX ${CMAKE_CXX_FLAGS}")
find_path(LOG4CXX_INCLUDE_PATH log4cxx/logger.h)
endif (USE_LOG4CXX)

if (NOT APPLE AND NOT MSVC)
# Hide all non-exported symbols to avoid conflicts
add_compile_options(-fvisibility=hidden)
Expand Down Expand Up @@ -323,7 +286,6 @@ include_directories(
${ZLIB_INCLUDE_DIRS}
${CURL_INCLUDE_DIRS}
${Protobuf_INCLUDE_DIRS}
${LOG4CXX_INCLUDE_PATH}
${GTEST_INCLUDE_PATH}
${GMOCK_INCLUDE_PATH}
)
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ If you want to enable other compression types, you need to install:

If you want to build and run the tests, you need to install [GTest](https://github.com/google/googletest). Otherwise, you need to add CMake option `-DBUILD_TESTS=OFF`.

If you want to use `ClientConfiguration::setLogConfFilePath`, you need to install the [Log4CXX](https://logging.apache.org/log4cxx) and add CMake option `-DUSE_LOG4CXX=ON`.

The [dependencies.yaml](./dependencies.yaml) file provides the recommended dependency versions, while you can still build from source with other dependency versions. If a dependency requires a higher C++ standard, e.g. C++14, you can specify the standard like:

```bash
Expand Down
13 changes: 0 additions & 13 deletions include/pulsar/ClientConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,6 @@ class PULSAR_PUBLIC ClientConfiguration {
*/
int getMaxBackoffIntervalMs() const;

/**
* Initialize the log configuration
*
* @param logConfFilePath path of the configuration file
* @deprecated
*/
ClientConfiguration& setLogConfFilePath(const std::string& logConfFilePath);

/**
* Get the path of log configuration file (log4cpp)
*/
const std::string& getLogConfFilePath() const;

/**
* Configure a custom logger backend to route of Pulsar client library
* to a different logger implementation.
Expand Down
7 changes: 0 additions & 7 deletions lib/ClientConfiguration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,6 @@ ClientConfiguration& ClientConfiguration::setMaxBackoffIntervalMs(int maxBackoff

int ClientConfiguration::getMaxBackoffIntervalMs() const { return impl_->maxBackoffIntervalMs; }

ClientConfiguration& ClientConfiguration::setLogConfFilePath(const std::string& logConfFilePath) {
impl_->logConfFilePath = logConfFilePath;
return *this;
}

const std::string& ClientConfiguration::getLogConfFilePath() const { return impl_->logConfFilePath; }

ClientConfiguration& ClientConfiguration::setLogger(LoggerFactory* loggerFactory) {
impl_->loggerFactory.reset(loggerFactory);
return *this;
Expand Down
1 change: 0 additions & 1 deletion lib/ClientConfigurationImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ struct ClientConfigurationImpl {
int maxLookupRedirects{20};
int initialBackoffIntervalMs{100};
int maxBackoffIntervalMs{60000};
std::string logConfFilePath;
bool useTls{false};
std::string tlsPrivateKeyFilePath;
std::string tlsCertificateFilePath;
Expand Down
14 changes: 0 additions & 14 deletions lib/ClientImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
#include "TimeUtils.h"
#include "TopicName.h"

#ifdef USE_LOG4CXX
#include "Log4CxxLogger.h"
#endif

#ifdef PULSAR_USE_BOOST_REGEX
#include <boost/regex.hpp>
#define PULSAR_REGEX_NAMESPACE boost
Expand Down Expand Up @@ -98,18 +94,8 @@ ClientImpl::ClientImpl(const std::string& serviceUrl, const ClientConfiguration&
closingError(ResultOk) {
std::unique_ptr<LoggerFactory> loggerFactory = clientConfiguration_.impl_->takeLogger();
if (!loggerFactory) {
#ifdef USE_LOG4CXX
if (!clientConfiguration_.getLogConfFilePath().empty()) {
// A log4cxx log file was passed through deprecated parameter. Use that to configure Log4CXX
loggerFactory = Log4CxxLoggerFactory::create(clientConfiguration_.getLogConfFilePath());
} else {
// Use default simple console logger
loggerFactory.reset(new ConsoleLoggerFactory);
}
#else
// Use default simple console logger
loggerFactory.reset(new ConsoleLoggerFactory);
#endif
}
LogUtils::setLoggerFactory(std::move(loggerFactory));

Expand Down
39 changes: 0 additions & 39 deletions lib/Log4CxxLogger.h

This file was deleted.

100 changes: 0 additions & 100 deletions lib/Log4cxxLogger.cc

This file was deleted.

14 changes: 0 additions & 14 deletions lib/LogUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,8 @@
#include <atomic>
#include <iostream>

#include "Log4CxxLogger.h"

namespace pulsar {

void LogUtils::init(const std::string& logfilePath) {
// If this is called explicitely, we fallback to Log4cxx config, if enabled

#ifdef USE_LOG4CXX
if (!logfilePath.empty()) {
setLoggerFactory(Log4CxxLoggerFactory::create(logfilePath));
} else {
setLoggerFactory(Log4CxxLoggerFactory::create());
}
#endif // USE_LOG4CXX
}

static std::atomic<LoggerFactory*> s_loggerFactory(nullptr);

void LogUtils::setLoggerFactory(std::unique_ptr<LoggerFactory> loggerFactory) {
Expand Down
2 changes: 0 additions & 2 deletions lib/LogUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ namespace pulsar {

class PULSAR_PUBLIC LogUtils {
public:
static void init(const std::string& logConfFilePath);

static void setLoggerFactory(std::unique_ptr<LoggerFactory> loggerFactory);

static void resetLoggerFactory();
Expand Down
2 changes: 0 additions & 2 deletions tests/BasicEndToEndTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -681,15 +681,13 @@ TEST(BasicEndToEndTest, testConfigurationFile) {
config1.setOperationTimeoutSeconds(100);
config1.setIOThreads(10);
config1.setMessageListenerThreads(1);
config1.setLogConfFilePath("/tmp/");

ClientConfiguration config2 = config1;
AuthenticationDataPtr authData;
ASSERT_EQ(ResultOk, config1.getAuth().getAuthData(authData));
ASSERT_EQ(100, config2.getOperationTimeoutSeconds());
ASSERT_EQ(10, config2.getIOThreads());
ASSERT_EQ(1, config2.getMessageListenerThreads());
ASSERT_EQ(config2.getLogConfFilePath().compare("/tmp/"), 0);
}

TEST(BasicEndToEndTest, testSinglePartitionRoutingPolicy) {
Expand Down
1 change: 0 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"snappy",
"zlib",
"zstd",
"log4cxx",
{
"name": "dlfcn-win32",
"platform": "windows"
Expand Down