blob: 6f3718a2aa342b6d9118d7faf40f700ea05a1f1f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#pragma once
#include <util/generic/ptr.h>
namespace NTvmAuth {
class ILogger: public TAtomicRefCount<ILogger> {
public:
virtual ~ILogger() = default;
void Debug(const TString& msg) {
Log(7, msg);
}
void Info(const TString& msg) {
Log(6, msg);
}
void Warning(const TString& msg) {
Log(4, msg);
}
void Error(const TString& msg) {
Log(3, msg);
}
protected:
/*!
* Log event
* @param lvl is syslog level: 0(Emergency) ... 7(Debug)
* @param msg
*/
virtual void Log(int lvl, const TString& msg) = 0;
};
class TCerrLogger: public ILogger {
public:
TCerrLogger(int level)
: Level_(level)
{
}
void Log(int lvl, const TString& msg) override;
private:
const int Level_;
};
using TLoggerPtr = TIntrusivePtr<ILogger>;
class TDevNullLogger: public ILogger {
public:
static TLoggerPtr IAmBrave() {
return MakeIntrusive<TDevNullLogger>();
}
void Log(int, const TString&) override {
}
};
}
|