2020-10-10 18:37:02 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-06-14 14:00:37 +00:00
|
|
|
#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"
|
2019-06-14 14:00:37 +00:00
|
|
|
|
2021-05-04 17:43:23 +00:00
|
|
|
|
2019-06-14 14:00:37 +00:00
|
|
|
namespace Poco::Util
|
|
|
|
{
|
2019-09-03 19:48:29 +00:00
|
|
|
class AbstractConfiguration;
|
|
|
|
}
|
|
|
|
|
2019-06-14 14:00:37 +00:00
|
|
|
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.
|
2019-06-14 14:00:37 +00:00
|
|
|
void closeLogs(Poco::Logger & logger);
|
|
|
|
|
2024-05-22 11:18:51 +00:00
|
|
|
virtual ~Loggers() = default;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool allowTextLog() const { return true; }
|
2019-07-30 14:04:18 +00:00
|
|
|
|
2019-06-14 14:00:37 +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
|
|
|
|
2019-06-14 14:00:37 +00:00
|
|
|
/// Previous value of logger element in config. It is used to reinitialize loggers whenever the value changed.
|
2023-06-02 00:50:14 +00:00
|
|
|
std::optional<std::string> config_logger;
|
2019-07-30 14:04:18 +00:00
|
|
|
|
2020-01-23 20:19:51 +00:00
|
|
|
|
2019-07-30 14:04:18 +00:00
|
|
|
Poco::AutoPtr<DB::OwnSplitChannel> split;
|
2019-06-14 14:00:37 +00:00
|
|
|
};
|