mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Add name to logger in queue
This commit is contained in:
parent
220c0255ab
commit
4a10c7286e
@ -39,12 +39,14 @@ namespace
|
||||
ISystemLog::~ISystemLog() = default;
|
||||
|
||||
template <typename LogElement>
|
||||
SystemLogBase<LogElement>::SystemLogBase(std::shared_ptr<SystemLogQueue<LogElement>> ex_queue)
|
||||
SystemLogBase<LogElement>::SystemLogBase(
|
||||
const String & name_,
|
||||
std::shared_ptr<SystemLogQueue<LogElement>> queue_)
|
||||
{
|
||||
if (ex_queue)
|
||||
queue = ex_queue;
|
||||
if (queue_)
|
||||
queue = queue_;
|
||||
else
|
||||
queue = std::make_shared<SystemLogQueue<LogElement>>();
|
||||
queue = std::make_shared<SystemLogQueue<LogElement>>(name_);
|
||||
}
|
||||
|
||||
template <typename LogElement>
|
||||
@ -75,6 +77,11 @@ void SystemLogBase<LogElement>::startup()
|
||||
saving_thread = std::make_unique<ThreadFromGlobalPool>([this] { savingThreadFunction(); });
|
||||
}
|
||||
|
||||
template <typename LogElement>
|
||||
SystemLogQueue<LogElement>::SystemLogQueue(const String & name_)
|
||||
: log(&Poco::Logger::get(name_))
|
||||
{}
|
||||
|
||||
static thread_local bool recursive_add_call = false;
|
||||
|
||||
template <typename LogElement>
|
||||
@ -92,7 +99,6 @@ void SystemLogQueue<LogElement>::add(const LogElement & element)
|
||||
/// Otherwise the tests like 01017_uniqCombined_memory_usage.sql will be flacky.
|
||||
MemoryTrackerBlockerInThread temporarily_disable_memory_tracker;
|
||||
|
||||
|
||||
/// Should not log messages under mutex.
|
||||
bool queue_is_half_full = false;
|
||||
|
||||
@ -194,4 +200,7 @@ void SystemLogBase<LogElement>::flush(bool force)
|
||||
#define INSTANTIATE_SYSTEM_LOG_BASE(ELEMENT) template class SystemLogBase<ELEMENT>;
|
||||
SYSTEM_LOG_ELEMENTS(INSTANTIATE_SYSTEM_LOG_BASE)
|
||||
|
||||
#define INSTANTIATE_SYSTEM_LOG_BASE2(ELEMENT) template class SystemLogQueue<ELEMENT>;
|
||||
SYSTEM_LOG_ELEMENTS(INSTANTIATE_SYSTEM_LOG_BASE2)
|
||||
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ template <typename LogElement>
|
||||
class SystemLogQueue
|
||||
{
|
||||
public:
|
||||
SystemLogQueue(const String & name_);
|
||||
|
||||
void add(const LogElement & element);
|
||||
size_t size() const { return queue.size(); }
|
||||
@ -109,7 +110,9 @@ class SystemLogBase : public ISystemLog
|
||||
public:
|
||||
using Self = SystemLogBase;
|
||||
|
||||
SystemLogBase(std::shared_ptr<SystemLogQueue<LogElement>> ex_queue = nullptr);
|
||||
SystemLogBase(
|
||||
const String & name_,
|
||||
std::shared_ptr<SystemLogQueue<LogElement>> queue_ = nullptr);
|
||||
|
||||
/** Append a record into log.
|
||||
* Writing to table will be done asynchronously and in case of failure, record could be lost.
|
||||
|
@ -333,8 +333,8 @@ SystemLog<LogElement>::SystemLog(
|
||||
const String & table_name_,
|
||||
const String & storage_def_,
|
||||
size_t flush_interval_milliseconds_,
|
||||
std::shared_ptr<SystemLogQueue<LogElement>> ex_queue)
|
||||
: Base(ex_queue)
|
||||
std::shared_ptr<SystemLogQueue<LogElement>> queue_)
|
||||
: Base(database_name_ + "." + table_name_, queue_)
|
||||
, WithContext(context_)
|
||||
, table_id(database_name_, table_name_)
|
||||
, storage_def(storage_def_)
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
|
||||
static std::shared_ptr<SystemLogQueue<TextLogElement>> getLogQueue()
|
||||
{
|
||||
static std::shared_ptr<SystemLogQueue<TextLogElement>> queue = std::make_shared<SystemLogQueue<TextLogElement>>();
|
||||
static std::shared_ptr<SystemLogQueue<TextLogElement>> queue = std::make_shared<SystemLogQueue<TextLogElement>>("text_log");
|
||||
return queue;
|
||||
}
|
||||
};
|
||||
|
@ -49,15 +49,6 @@ void Loggers::buildLoggers(Poco::Util::AbstractConfiguration & config, Poco::Log
|
||||
/// Use extended interface of Channel for more comprehensive logging.
|
||||
split = new DB::OwnSplitChannel();
|
||||
|
||||
#ifndef WITHOUT_TEXT_LOG
|
||||
if (config.has("text_log"))
|
||||
{
|
||||
String text_log_level_str = config.getString("text_log.level", "");
|
||||
int text_log_level = text_log_level_str.empty() ? INT_MAX : Poco::Logger::parseLevel(text_log_level_str);
|
||||
split->addTextLog(DB::TextLog::getLogQueue(), text_log_level);
|
||||
}
|
||||
#endif
|
||||
|
||||
auto log_level_string = config.getString("logger.level", "trace");
|
||||
|
||||
/// different channels (log, console, syslog) may have different loglevels configured
|
||||
@ -258,6 +249,14 @@ void Loggers::buildLoggers(Poco::Util::AbstractConfiguration & config, Poco::Log
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef WITHOUT_TEXT_LOG
|
||||
if (config.has("text_log"))
|
||||
{
|
||||
String text_log_level_str = config.getString("text_log.level", "");
|
||||
int text_log_level = text_log_level_str.empty() ? INT_MAX : Poco::Logger::parseLevel(text_log_level_str);
|
||||
split->addTextLog(DB::TextLog::getLogQueue(), text_log_level);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Loggers::updateLevels(Poco::Util::AbstractConfiguration & config, Poco::Logger & logger)
|
||||
|
Loading…
Reference in New Issue
Block a user