2018-06-15 17:32:35 +00:00
|
|
|
#pragma once
|
|
|
|
#include <Poco/AutoPtr.h>
|
|
|
|
#include <Poco/Channel.h>
|
|
|
|
#include <Poco/FormattingChannel.h>
|
2019-06-14 14:00:37 +00:00
|
|
|
#include "ExtendedLogChannel.h"
|
2018-08-21 18:35:31 +00:00
|
|
|
#include "OwnPatternFormatter.h"
|
2018-06-15 17:32:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
// Like Poco::FormattingChannel but supports the extended logging interface and log level filter
|
|
|
|
class OwnFormattingChannel : public Poco::Channel, public ExtendedLogChannel
|
|
|
|
{
|
|
|
|
public:
|
2019-06-14 14:00:37 +00:00
|
|
|
explicit OwnFormattingChannel(
|
|
|
|
Poco::AutoPtr<OwnPatternFormatter> pFormatter_ = nullptr, Poco::AutoPtr<Poco::Channel> pChannel_ = nullptr)
|
|
|
|
: pFormatter(std::move(pFormatter_)), pChannel(std::move(pChannel_))
|
2018-06-15 17:32:35 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-06-14 14:00:37 +00:00
|
|
|
void setChannel(Poco::AutoPtr<Poco::Channel> pChannel_) { pChannel = std::move(pChannel_); }
|
|
|
|
|
|
|
|
void setLevel(Poco::Message::Priority priority_) { priority = priority_; }
|
2018-06-15 17:32:35 +00:00
|
|
|
|
|
|
|
void open() override
|
|
|
|
{
|
|
|
|
if (pChannel)
|
|
|
|
pChannel->open();
|
|
|
|
}
|
|
|
|
|
|
|
|
void close() override
|
|
|
|
{
|
|
|
|
if (pChannel)
|
|
|
|
pChannel->close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void log(const Poco::Message & msg) override;
|
|
|
|
void logExtended(const ExtendedLogMessage & msg) override;
|
|
|
|
|
|
|
|
~OwnFormattingChannel() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Poco::AutoPtr<OwnPatternFormatter> pFormatter;
|
|
|
|
Poco::AutoPtr<Poco::Channel> pChannel;
|
|
|
|
Poco::Message::Priority priority = Poco::Message::PRIO_TRACE;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|