2018-06-15 17:32:35 +00:00
|
|
|
#pragma once
|
2019-07-19 07:44:18 +00:00
|
|
|
#include <atomic>
|
2018-06-15 17:32:35 +00:00
|
|
|
#include <vector>
|
2019-06-14 14:00:37 +00:00
|
|
|
#include <Poco/AutoPtr.h>
|
|
|
|
#include <Poco/Channel.h>
|
|
|
|
#include "ExtendedLogChannel.h"
|
2019-07-30 14:04:18 +00:00
|
|
|
#include <Interpreters/TextLog.h>
|
2018-06-15 17:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
/// Works as Poco::SplitterChannel, but performs additional work:
|
|
|
|
/// passes logs to Client via TCP interface
|
|
|
|
/// tries to use extended logging interface of child for more comprehensive logging
|
|
|
|
class OwnSplitChannel : public Poco::Channel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// Makes an extended message from msg and passes it to the client logs queue and child (if possible)
|
|
|
|
void log(const Poco::Message & msg) override;
|
|
|
|
/// Adds a child channel
|
|
|
|
void addChannel(Poco::AutoPtr<Poco::Channel> channel);
|
|
|
|
|
2020-01-23 20:19:51 +00:00
|
|
|
void addTextLog(std::shared_ptr<DB::TextLog> log, int max_priority);
|
2019-07-30 14:04:18 +00:00
|
|
|
|
2018-06-15 17:32:35 +00:00
|
|
|
private:
|
2019-06-20 07:17:21 +00:00
|
|
|
void logSplit(const Poco::Message & msg);
|
|
|
|
|
2018-06-15 17:32:35 +00:00
|
|
|
using ChannelPtr = Poco::AutoPtr<Poco::Channel>;
|
|
|
|
/// Handler and its pointer casted to extended interface
|
|
|
|
using ExtendedChannelPtrPair = std::pair<ChannelPtr, ExtendedLogChannel *>;
|
|
|
|
std::vector<ExtendedChannelPtrPair> channels;
|
2019-07-30 14:04:18 +00:00
|
|
|
|
2019-07-31 14:42:23 +00:00
|
|
|
std::mutex text_log_mutex;
|
2019-09-06 17:48:27 +00:00
|
|
|
|
2019-07-30 14:04:18 +00:00
|
|
|
std::weak_ptr<DB::TextLog> text_log;
|
2020-01-23 20:19:51 +00:00
|
|
|
int text_log_max_priority = -1;
|
2018-06-15 17:32:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|