ClickHouse/libs/libloggers/loggers/OwnFormattingChannel.h
proller 09f3d68f6e Use logging in clickhouse-local. Use config options in command line in clickhouse-client (#5540)
* Try fix macos server run

* Doc macos build
 # Please enter the commit message for your changes. Lines starting

* CLICKHOUSE-3957 start wip

* tests wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* fix

* fix

* Making logger for clickhouse-local

* fixes

* wip

* wip

* wip

* wip

* clean

*      cf

* wip

* fix

* Update CMakeLists.txt

* Update argsToConfig.h

* Update argsToConfig.cpp

* Update ExtendedLogChannel.h

* Update OwnPatternFormatter.cpp
2019-06-14 17:00:37 +03:00

49 lines
1.3 KiB
C++

#pragma once
#include <Poco/AutoPtr.h>
#include <Poco/Channel.h>
#include <Poco/FormattingChannel.h>
#include "ExtendedLogChannel.h"
#include "OwnPatternFormatter.h"
namespace DB
{
// Like Poco::FormattingChannel but supports the extended logging interface and log level filter
class OwnFormattingChannel : public Poco::Channel, public ExtendedLogChannel
{
public:
explicit OwnFormattingChannel(
Poco::AutoPtr<OwnPatternFormatter> pFormatter_ = nullptr, Poco::AutoPtr<Poco::Channel> pChannel_ = nullptr)
: pFormatter(std::move(pFormatter_)), pChannel(std::move(pChannel_))
{
}
void setChannel(Poco::AutoPtr<Poco::Channel> pChannel_) { pChannel = std::move(pChannel_); }
void setLevel(Poco::Message::Priority priority_) { priority = priority_; }
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;
};
}