ClickHouse/base/loggers/Loggers.h

45 lines
1.1 KiB
C++
Raw Normal View History

2020-10-10 18:37:02 +00:00
#pragma once
#include <optional>
#include <string>
#include <Poco/AutoPtr.h>
#include <Poco/FileChannel.h>
#include <Poco/Util/Application.h>
2019-07-30 14:04:18 +00:00
#include "OwnSplitChannel.h"
2022-01-17 04:33:47 +00:00
namespace DB
{
class TextLog;
}
2021-05-04 17:43:23 +00:00
namespace Poco::Util
{
2019-09-03 19:48:29 +00:00
class AbstractConfiguration;
}
class Loggers
{
public:
void buildLoggers(Poco::Util::AbstractConfiguration & config, Poco::Logger & logger, const std::string & cmd_name = "");
2021-09-30 19:46:12 +00:00
void updateLevels(Poco::Util::AbstractConfiguration & config, Poco::Logger & logger);
2019-06-14 15:49:38 +00:00
/// Close log files. On next log write files will be reopened.
void closeLogs(Poco::Logger & logger);
void setTextLog(std::shared_ptr<DB::TextLog> log, int max_priority);
2019-07-30 14:04:18 +00:00
private:
Poco::AutoPtr<Poco::FileChannel> log_file;
Poco::AutoPtr<Poco::FileChannel> error_log_file;
Poco::AutoPtr<Poco::Channel> syslog_channel;
2019-06-20 07:17:21 +00:00
/// Previous value of logger element in config. It is used to reinitialize loggers whenever the value changed.
std::string config_logger;
2019-07-30 14:04:18 +00:00
std::weak_ptr<DB::TextLog> text_log;
int text_log_max_priority = -1;
2019-07-30 14:04:18 +00:00
Poco::AutoPtr<DB::OwnSplitChannel> split;
};