1#include <optional>
2#include <string>
3#include <Poco/AutoPtr.h>
4#include <Poco/FileChannel.h>
5#include <Poco/Util/Application.h>
6#include <Interpreters/TextLog.h>
7#include "OwnSplitChannel.h"
8
9namespace Poco::Util
10{
11 class AbstractConfiguration;
12}
13
14class Loggers
15{
16public:
17 void buildLoggers(Poco::Util::AbstractConfiguration & config, Poco::Logger & logger, const std::string & cmd_name = "");
18
19 /// Close log files. On next log write files will be reopened.
20 void closeLogs(Poco::Logger & logger);
21
22 std::optional<size_t> getLayer() const
23 {
24 return layer; /// layer setted in inheritor class BaseDaemonApplication.
25 }
26
27 void setTextLog(std::shared_ptr<DB::TextLog> log);
28
29protected:
30 std::optional<size_t> layer;
31
32private:
33 Poco::AutoPtr<Poco::FileChannel> log_file;
34 Poco::AutoPtr<Poco::FileChannel> error_log_file;
35 Poco::AutoPtr<Poco::Channel> syslog_channel;
36
37 /// Previous value of logger element in config. It is used to reinitialize loggers whenever the value changed.
38 std::string config_logger;
39
40 std::weak_ptr<DB::TextLog> text_log;
41 Poco::AutoPtr<DB::OwnSplitChannel> split;
42};
43