aboutsummaryrefslogtreecommitdiffstats
path: root/kikimr/persqueue/sdk/deprecated/cpp/v2/logger.h
diff options
context:
space:
mode:
authorkomels <komels@yandex-team.ru>2022-04-14 13:10:53 +0300
committerkomels <komels@yandex-team.ru>2022-04-14 13:10:53 +0300
commit21c9b0e6b039e9765eb414c406c2b86e8cea6850 (patch)
treef40ebc18ff8958dfbd189954ad024043ca983ea5 /kikimr/persqueue/sdk/deprecated/cpp/v2/logger.h
parent9a4effa852abe489707139c2b260dccc6f4f9aa9 (diff)
downloadydb-21c9b0e6b039e9765eb414c406c2b86e8cea6850.tar.gz
Final part on compatibility layer: LOGBROKER-7215
ref:777c67aadbf705d19034a09a792b2df61ba53697
Diffstat (limited to 'kikimr/persqueue/sdk/deprecated/cpp/v2/logger.h')
-rw-r--r--kikimr/persqueue/sdk/deprecated/cpp/v2/logger.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/kikimr/persqueue/sdk/deprecated/cpp/v2/logger.h b/kikimr/persqueue/sdk/deprecated/cpp/v2/logger.h
new file mode 100644
index 0000000000..bb3320d795
--- /dev/null
+++ b/kikimr/persqueue/sdk/deprecated/cpp/v2/logger.h
@@ -0,0 +1,42 @@
+#pragma once
+#include <util/generic/ptr.h>
+#include <util/generic/string.h>
+
+namespace NPersQueue {
+
+class ILogger : public TAtomicRefCount<ILogger> {
+public:
+ virtual ~ILogger() = default;
+ //level = syslog level
+ virtual void Log(const TString& msg, const TString& sourceId, const TString& sessionId, int level) = 0;
+ virtual bool IsEnabled(int level) const = 0;
+};
+
+class TCerrLogger : public ILogger {
+public:
+ explicit TCerrLogger(int level)
+ : Level(level)
+ {
+ }
+
+ ~TCerrLogger() override = default;
+
+ void Log(const TString& msg, const TString& sourceId, const TString& sessionId, int level) override;
+
+ bool IsEnabled(int level) const override
+ {
+ return level <= Level;
+ }
+
+ int GetLevel() const {
+ return Level;
+ }
+
+private:
+ static TStringBuf LevelToString(int level);
+
+private:
+ int Level;
+};
+
+}