diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/logger/system.h | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/logger/system.h')
-rw-r--r-- | library/cpp/logger/system.h | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/library/cpp/logger/system.h b/library/cpp/logger/system.h index b8c60b3023..a4e38dece8 100644 --- a/library/cpp/logger/system.h +++ b/library/cpp/logger/system.h @@ -1,66 +1,66 @@ #pragma once -#include "log.h" -#include "backend.h" -#include "priority.h" - -#define YSYSLOG(priority, ...) SysLogInstance().AddLog((priority), __VA_ARGS__) -#define YSYSLOGINIT_FLAGS(ident, facility, flags) \ - struct TLogIniter { \ - TLogIniter() { \ +#include "log.h" +#include "backend.h" +#include "priority.h" + +#define YSYSLOG(priority, ...) SysLogInstance().AddLog((priority), __VA_ARGS__) +#define YSYSLOGINIT_FLAGS(ident, facility, flags) \ + struct TLogIniter { \ + TLogIniter() { \ SysLogInstance().ResetBackend(THolder<TLogBackend>( \ (ident) ? (TLogBackend*)(new TSysLogBackend((ident), (facility), (flags))) : (TLogBackend*)(new TNullLogBackend())));\ - } \ + } \ } Y_CAT(loginit, __LINE__); -#define YSYSLOGINIT(ident, facility) YSYSLOGINIT_FLAGS((ident), (facility), 0) +#define YSYSLOGINIT(ident, facility) YSYSLOGINIT_FLAGS((ident), (facility), 0) class TSysLogBackend: public TLogBackend { -public: - enum EFacility { - TSYSLOG_LOCAL0 = 0, - TSYSLOG_LOCAL1 = 1, - TSYSLOG_LOCAL2 = 2, - TSYSLOG_LOCAL3 = 3, - TSYSLOG_LOCAL4 = 4, - TSYSLOG_LOCAL5 = 5, - TSYSLOG_LOCAL6 = 6, - TSYSLOG_LOCAL7 = 7 - }; +public: + enum EFacility { + TSYSLOG_LOCAL0 = 0, + TSYSLOG_LOCAL1 = 1, + TSYSLOG_LOCAL2 = 2, + TSYSLOG_LOCAL3 = 3, + TSYSLOG_LOCAL4 = 4, + TSYSLOG_LOCAL5 = 5, + TSYSLOG_LOCAL6 = 6, + TSYSLOG_LOCAL7 = 7 + }; - enum EFlags { - LogPerror = 1, - LogCons = 2 - }; + enum EFlags { + LogPerror = 1, + LogCons = 2 + }; - TSysLogBackend(const char* ident, EFacility facility, int flags = 0); - ~TSysLogBackend() override; + TSysLogBackend(const char* ident, EFacility facility, int flags = 0); + ~TSysLogBackend() override; - void WriteData(const TLogRecord& rec) override; - void ReopenLog() override; + void WriteData(const TLogRecord& rec) override; + void ReopenLog() override; virtual TString GetIdent() const { - return Ident; - } + return Ident; + } - virtual EFacility GetFacility() const { - return Facility; - } + virtual EFacility GetFacility() const { + return Facility; + } - virtual int GetFlags() const { - return Flags; - } + virtual int GetFlags() const { + return Flags; + } -protected: +protected: int ELogPriority2SyslogPriority(ELogPriority priority); TString Ident; - EFacility Facility; - int Flags; + EFacility Facility; + int Flags; }; -/* - * return system-wide logger instance - * better do not use in real programs(instead of robot, of course) - */ -TLog& SysLogInstance(); +/* + * return system-wide logger instance + * better do not use in real programs(instead of robot, of course) + */ +TLog& SysLogInstance(); |