blob: 1c35c7c5ee040a1894e866dc592ae630627c6733 (
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
|
#pragma once
#include <library/cpp/yt/string/raw_formatter.h>
#include <library/cpp/yt/logging//logger.h>
namespace NYT::NLogging {
/////////////////////////////////////////////////////////////π///////////////////
constexpr int DateTimeBufferSize = 64;
constexpr int MessageBufferSize = 64_KB;
void FormatMilliseconds(TBaseFormatter* out, TInstant dateTime);
void FormatMicroseconds(TBaseFormatter* out, TInstant dateTime);
void FormatLevel(TBaseFormatter* out, ELogLevel level);
void FormatMessage(TBaseFormatter* out, TStringBuf message);
/////////////////////////////////////////////////////////////π///////////////////
class TCachingDateFormatter
{
public:
void Format(TBaseFormatter* buffer, TInstant dateTime, bool printMicroseconds = false);
private:
ui64 CachedSecond_ = 0;
TRawFormatter<DateTimeBufferSize> Cached_;
};
////////////////////////////////////////////////////////////////////////////////
class TPlainTextEventFormatter
{
public:
explicit TPlainTextEventFormatter(bool enableSourceLocation);
void Format(TBaseFormatter* buffer, const TLogEvent& event);
private:
const bool EnableSourceLocation_;
TCachingDateFormatter CachingDateFormatter_;
};
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT::NLogging
|