From b92c383d4beec3fab48cd989432aaba44353617d Mon Sep 17 00:00:00 2001 From: Dmitry Novik Date: Tue, 6 Sep 2022 19:57:09 +0200 Subject: [PATCH 1/2] Try to fix ODR for Loggers class --- src/Daemon/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Daemon/CMakeLists.txt b/src/Daemon/CMakeLists.txt index 78c133d9893..60dec62155e 100644 --- a/src/Daemon/CMakeLists.txt +++ b/src/Daemon/CMakeLists.txt @@ -3,6 +3,7 @@ add_library (daemon GraphiteWriter.cpp SentryWriter.cpp ) +target_compile_definitions(daemon PUBLIC WITH_TEXT_LOG=1) if (OS_DARWIN AND NOT USE_STATIC_LIBRARIES) target_link_libraries (daemon PUBLIC -Wl,-undefined,dynamic_lookup) From 29b5d023eeb352960d71b2fe1783ffb5b588e798 Mon Sep 17 00:00:00 2001 From: Dmitry Novik Date: Thu, 8 Sep 2022 19:16:37 +0200 Subject: [PATCH 2/2] Replace WITH_TEXT_LOG by WITHOUT_TEXT_LOG --- programs/keeper/CMakeLists.txt | 1 + src/Daemon/CMakeLists.txt | 1 - src/Loggers/CMakeLists.txt | 2 +- src/Loggers/Loggers.cpp | 6 +++--- src/Loggers/Loggers.h | 6 +++--- src/Loggers/OwnSplitChannel.cpp | 6 +++--- src/Loggers/OwnSplitChannel.h | 6 +++--- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/programs/keeper/CMakeLists.txt b/programs/keeper/CMakeLists.txt index 36e37eda91f..a5ad506abe6 100644 --- a/programs/keeper/CMakeLists.txt +++ b/programs/keeper/CMakeLists.txt @@ -103,6 +103,7 @@ if (BUILD_STANDALONE_KEEPER) # Remove some redundant dependencies target_compile_definitions (clickhouse-keeper PRIVATE -DKEEPER_STANDALONE_BUILD) + target_compile_definitions (clickhouse-keeper PUBLIC -DWITHOUT_TEXT_LOG) target_include_directories(clickhouse-keeper PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../../src") # uses includes from src directory target_include_directories(clickhouse-keeper PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/../../src/Core/include") # uses some includes from core diff --git a/src/Daemon/CMakeLists.txt b/src/Daemon/CMakeLists.txt index 60dec62155e..78c133d9893 100644 --- a/src/Daemon/CMakeLists.txt +++ b/src/Daemon/CMakeLists.txt @@ -3,7 +3,6 @@ add_library (daemon GraphiteWriter.cpp SentryWriter.cpp ) -target_compile_definitions(daemon PUBLIC WITH_TEXT_LOG=1) if (OS_DARWIN AND NOT USE_STATIC_LIBRARIES) target_link_libraries (daemon PUBLIC -Wl,-undefined,dynamic_lookup) diff --git a/src/Loggers/CMakeLists.txt b/src/Loggers/CMakeLists.txt index 02a886765a1..1f32d747b01 100644 --- a/src/Loggers/CMakeLists.txt +++ b/src/Loggers/CMakeLists.txt @@ -2,9 +2,9 @@ add_headers_and_sources(loggers .) # Standard version depends on DBMS and works with text log add_library(loggers ${loggers_sources} ${loggers_headers}) -target_compile_definitions(loggers PUBLIC WITH_TEXT_LOG=1) target_link_libraries(loggers PRIVATE dbms clickhouse_common_io) # Lightweight version doesn't work with textlog and also doesn't depend on DBMS add_library(loggers_no_text_log ${loggers_sources} ${loggers_headers}) +target_compile_definitions(loggers_no_text_log PUBLIC WITHOUT_TEXT_LOG=1) target_link_libraries(loggers_no_text_log PRIVATE clickhouse_common_io) diff --git a/src/Loggers/Loggers.cpp b/src/Loggers/Loggers.cpp index 97e26f2c038..b3bd8d588cd 100644 --- a/src/Loggers/Loggers.cpp +++ b/src/Loggers/Loggers.cpp @@ -10,7 +10,7 @@ #include #include -#ifdef WITH_TEXT_LOG +#ifndef WITHOUT_TEXT_LOG #include #endif @@ -34,7 +34,7 @@ static std::string createDirectory(const std::string & file) return path; } -#ifdef WITH_TEXT_LOG +#ifndef WITHOUT_TEXT_LOG void Loggers::setTextLog(std::shared_ptr log, int max_priority) { text_log = log; @@ -44,7 +44,7 @@ void Loggers::setTextLog(std::shared_ptr log, int max_priority) void Loggers::buildLoggers(Poco::Util::AbstractConfiguration & config, Poco::Logger & logger /*_root*/, const std::string & cmd_name) { -#ifdef WITH_TEXT_LOG +#ifndef WITHOUT_TEXT_LOG if (split) if (auto log = text_log.lock()) split->addTextLog(log, text_log_max_priority); diff --git a/src/Loggers/Loggers.h b/src/Loggers/Loggers.h index 22b2b5e2c69..31a215aa9ce 100644 --- a/src/Loggers/Loggers.h +++ b/src/Loggers/Loggers.h @@ -7,7 +7,7 @@ #include #include "OwnSplitChannel.h" -#ifdef WITH_TEXT_LOG +#ifndef WITHOUT_TEXT_LOG namespace DB { class TextLog; @@ -29,7 +29,7 @@ public: /// Close log files. On next log write files will be reopened. void closeLogs(Poco::Logger & logger); -#ifdef WITH_TEXT_LOG +#ifndef WITHOUT_TEXT_LOG void setTextLog(std::shared_ptr log, int max_priority); #endif @@ -41,7 +41,7 @@ private: /// Previous value of logger element in config. It is used to reinitialize loggers whenever the value changed. std::string config_logger; -#ifdef WITH_TEXT_LOG +#ifndef WITHOUT_TEXT_LOG std::weak_ptr text_log; int text_log_max_priority = -1; #endif diff --git a/src/Loggers/OwnSplitChannel.cpp b/src/Loggers/OwnSplitChannel.cpp index 933fc09d3e4..f9f4ad8a1c3 100644 --- a/src/Loggers/OwnSplitChannel.cpp +++ b/src/Loggers/OwnSplitChannel.cpp @@ -21,7 +21,7 @@ namespace DB void OwnSplitChannel::log(const Poco::Message & msg) { -#ifdef WITH_TEXT_LOG +#ifndef WITHOUT_TEXT_LOG auto logs_queue = CurrentThread::getInternalTextLogsQueue(); if (channels.empty() && (logs_queue == nullptr || !logs_queue->isNeeded(msg.getPriority(), msg.getSource()))) @@ -89,7 +89,7 @@ void OwnSplitChannel::logSplit(const Poco::Message & msg) channel.first->log(msg); // ordinary child } -#ifdef WITH_TEXT_LOG +#ifndef WITHOUT_TEXT_LOG auto logs_queue = CurrentThread::getInternalTextLogsQueue(); /// Log to "TCP queue" if message is not too noisy @@ -150,7 +150,7 @@ void OwnSplitChannel::addChannel(Poco::AutoPtr channel, const std channels.emplace(name, ExtendedChannelPtrPair(std::move(channel), dynamic_cast(channel.get()))); } -#ifdef WITH_TEXT_LOG +#ifndef WITHOUT_TEXT_LOG void OwnSplitChannel::addTextLog(std::shared_ptr log, int max_priority) { std::lock_guard lock(text_log_mutex); diff --git a/src/Loggers/OwnSplitChannel.h b/src/Loggers/OwnSplitChannel.h index 16231c105b7..80305c1ccee 100644 --- a/src/Loggers/OwnSplitChannel.h +++ b/src/Loggers/OwnSplitChannel.h @@ -7,7 +7,7 @@ #include #include "ExtendedLogChannel.h" -#ifdef WITH_TEXT_LOG +#ifndef WITHOUT_TEXT_LOG namespace DB { class TextLog; @@ -30,7 +30,7 @@ public: /// Adds a child channel void addChannel(Poco::AutoPtr channel, const std::string & name); -#ifdef WITH_TEXT_LOG +#ifndef WITHOUT_TEXT_LOG void addTextLog(std::shared_ptr log, int max_priority); #endif @@ -47,7 +47,7 @@ private: std::mutex text_log_mutex; -#ifdef WITH_TEXT_LOG +#ifndef WITHOUT_TEXT_LOG std::weak_ptr text_log; std::atomic text_log_max_priority = -1; #endif