aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Loggers/OwnPatternFormatter.h
blob: 8b0d11bcec121f3239f57f5b651512840ec1a53b (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
#pragma once


#include <Poco/PatternFormatter.h>
#include <Common/DateLUT.h>
#include "ExtendedLogChannel.h"


/** Format log messages own way.
  * We can't obtain some details using Poco::PatternFormatter.
  *
  * Firstly, the thread number here is peaked not from Poco::Thread
  * threads only, but from all threads with number assigned (see ThreadNumber.h)
  *
  * Secondly, the local date and time are correctly displayed.
  * Poco::PatternFormatter does not work well with local time,
  * when timestamps are close to DST timeshift moments.
  * - see Poco sources and http://thread.gmane.org/gmane.comp.time.tz/8883
  *
  * Also it's made a bit more efficient (unimportant).
  */

class Loggers;

class OwnPatternFormatter : public Poco::PatternFormatter
{
public:
    OwnPatternFormatter(bool color_ = false);

    void format(const Poco::Message & msg, std::string & text) override;
    virtual void formatExtended(const DB::ExtendedLogMessage & msg_ext, std::string & text) const;

private:
    const DateLUTImpl & server_timezone = DateLUT::serverTimezoneInstance();
    bool color;
};