aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Loggers/OwnSplitChannel.h
diff options
context:
space:
mode:
authorvitalyisaev <vitalyisaev@ydb.tech>2023-11-14 09:58:56 +0300
committervitalyisaev <vitalyisaev@ydb.tech>2023-11-14 10:20:20 +0300
commitc2b2dfd9827a400a8495e172a56343462e3ceb82 (patch)
treecd4e4f597d01bede4c82dffeb2d780d0a9046bd0 /contrib/clickhouse/src/Loggers/OwnSplitChannel.h
parentd4ae8f119e67808cb0cf776ba6e0cf95296f2df7 (diff)
downloadydb-c2b2dfd9827a400a8495e172a56343462e3ceb82.tar.gz
YQ Connector: move tests from yql to ydb (OSS)
Перенос папки с тестами на Коннектор из папки yql в папку ydb (синхронизируется с github).
Diffstat (limited to 'contrib/clickhouse/src/Loggers/OwnSplitChannel.h')
-rw-r--r--contrib/clickhouse/src/Loggers/OwnSplitChannel.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/contrib/clickhouse/src/Loggers/OwnSplitChannel.h b/contrib/clickhouse/src/Loggers/OwnSplitChannel.h
new file mode 100644
index 0000000000..a6ee8af5b1
--- /dev/null
+++ b/contrib/clickhouse/src/Loggers/OwnSplitChannel.h
@@ -0,0 +1,56 @@
+#pragma once
+#include <atomic>
+#include <vector>
+#include <map>
+#include <mutex>
+#include <Poco/AutoPtr.h>
+#include <Poco/Channel.h>
+#include "ExtendedLogChannel.h"
+
+#ifndef WITHOUT_TEXT_LOG
+namespace DB
+{
+ template <typename> class SystemLogQueue;
+ struct TextLogElement;
+ using TextLogQueue = SystemLogQueue<TextLogElement>;
+}
+#endif
+
+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;
+
+ void setChannelProperty(const std::string& channel_name, const std::string& name, const std::string& value);
+
+ /// Adds a child channel
+ void addChannel(Poco::AutoPtr<Poco::Channel> channel, const std::string & name);
+
+#ifndef WITHOUT_TEXT_LOG
+ void addTextLog(std::shared_ptr<DB::TextLogQueue> log_queue, int max_priority);
+#endif
+
+ void setLevel(const std::string & name, int level);
+
+private:
+ void logSplit(const Poco::Message & msg);
+ void tryLogSplit(const Poco::Message & msg);
+
+ using ChannelPtr = Poco::AutoPtr<Poco::Channel>;
+ /// Handler and its pointer casted to extended interface
+ using ExtendedChannelPtrPair = std::pair<ChannelPtr, ExtendedLogChannel *>;
+ std::map<std::string, ExtendedChannelPtrPair> channels;
+
+#ifndef WITHOUT_TEXT_LOG
+ std::weak_ptr<DB::TextLogQueue> text_log;
+ std::atomic<int> text_log_max_priority = -1;
+#endif
+};
+
+}