1 | #pragma once |
2 | |
3 | |
4 | #include <Poco/PatternFormatter.h> |
5 | #include "ExtendedLogChannel.h" |
6 | |
7 | |
8 | /** Format log messages own way. |
9 | * We can't obtain some details using Poco::PatternFormatter. |
10 | * |
11 | * Firstly, the thread number here is peaked not from Poco::Thread |
12 | * threads only, but from all threads with number assigned (see ThreadNumber.h) |
13 | * |
14 | * Secondly, the local date and time are correctly displayed. |
15 | * Poco::PatternFormatter does not work well with local time, |
16 | * when timestamps are close to DST timeshift moments. |
17 | * - see Poco sources and http://thread.gmane.org/gmane.comp.time.tz/8883 |
18 | * |
19 | * Also it's made a bit more efficient (unimportant). |
20 | */ |
21 | |
22 | class Loggers; |
23 | |
24 | class OwnPatternFormatter : public Poco::PatternFormatter |
25 | { |
26 | public: |
27 | /// ADD_LAYER_TAG is needed only for Yandex.Metrika, that share part of ClickHouse code. |
28 | enum Options |
29 | { |
30 | ADD_NOTHING = 0, |
31 | ADD_LAYER_TAG = 1 << 0 |
32 | }; |
33 | |
34 | OwnPatternFormatter(const Loggers * loggers_, Options options_ = ADD_NOTHING); |
35 | |
36 | void format(const Poco::Message & msg, std::string & text) override; |
37 | void formatExtended(const DB::ExtendedLogMessage & msg_ext, std::string & text); |
38 | |
39 | private: |
40 | const Loggers * loggers; |
41 | Options options; |
42 | }; |
43 | |