Skip to content

Commit

Permalink
Ignore text_log for Keeper
Browse files Browse the repository at this point in the history
  • Loading branch information
antonio2368 committed May 22, 2024
1 parent 9b9f37a commit 5c47b09
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
5 changes: 5 additions & 0 deletions programs/keeper/Keeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ std::string Keeper::getDefaultConfigFileName() const
return "keeper_config.xml";
}

bool Keeper::allowTextLog() const
{
return false;
}

void Keeper::handleCustomArguments(const std::string & arg, [[maybe_unused]] const std::string & value) // NOLINT
{
if (arg == "force-recovery")
Expand Down
2 changes: 2 additions & 0 deletions programs/keeper/Keeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class Keeper : public BaseDaemon, public IServer

std::string getDefaultConfigFileName() const override;

bool allowTextLog() const override;

private:
Poco::Net::SocketAddress socketBindListen(Poco::Net::ServerSocket & socket, const std::string & host, UInt16 port, [[maybe_unused]] bool secure = false) const;

Expand Down
2 changes: 1 addition & 1 deletion src/Loggers/Loggers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void Loggers::buildLoggers(Poco::Util::AbstractConfiguration & config, Poco::Log
}
}
#ifndef WITHOUT_TEXT_LOG
if (config.has("text_log"))
if (allowTextLog() && config.has("text_log"))
{
String text_log_level_str = config.getString("text_log.level", "trace");
int text_log_level = Poco::Logger::parseLevel(text_log_level_str);
Expand Down
4 changes: 4 additions & 0 deletions src/Loggers/Loggers.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class Loggers
/// Close log files. On next log write files will be reopened.
void closeLogs(Poco::Logger & logger);

virtual ~Loggers() = default;

protected:
virtual bool allowTextLog() const { return true; }

private:
Poco::AutoPtr<Poco::FileChannel> log_file;
Expand Down
9 changes: 5 additions & 4 deletions src/Loggers/OwnSplitChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ void OwnSplitChannel::logSplit(const Poco::Message & msg)
[[maybe_unused]] bool push_result = logs_queue->emplace(std::move(columns));
}

auto text_log_locked = text_log.lock();
if (!text_log_locked)
return;

/// Also log to system.text_log table, if message is not too noisy
auto text_log_max_priority_loaded = text_log_max_priority.load(std::memory_order_relaxed);
if (text_log_max_priority_loaded && msg.getPriority() <= text_log_max_priority_loaded)
Expand Down Expand Up @@ -146,10 +150,7 @@ void OwnSplitChannel::logSplit(const Poco::Message & msg)

#undef SET_VALUE_IF_EXISTS

std::shared_ptr<SystemLogQueue<TextLogElement>> text_log_locked{};
text_log_locked = text_log.lock();
if (text_log_locked)
text_log_locked->push(std::move(elem));
text_log_locked->push(std::move(elem));
}
#endif
}
Expand Down
1 change: 0 additions & 1 deletion src/Loggers/OwnSplitChannel.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <atomic>
#include <vector>
#include <map>
#include <Poco/AutoPtr.h>
#include <Poco/Channel.h>
Expand Down

0 comments on commit 5c47b09

Please sign in to comment.