ClickHouse/libs/libloggers/loggers/OwnPatternFormatter.h

43 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
#include <Poco/PatternFormatter.h>
#include "ExtendedLogChannel.h"
2019-06-20 07:17:21 +00:00
/** Format log messages own way.
* We can't obtain some details using Poco::PatternFormatter.
*
2019-06-20 07:17:21 +00:00
* Firstly, the thread number here is peaked not from Poco::Thread
* threads only, but from all threads with number assigned (see ThreadNumber.h)
*
2019-06-20 07:17:21 +00:00
* 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
*
2019-06-20 07:17:21 +00:00
* Also it's made a bit more efficient (unimportant).
*/
class Loggers;
class OwnPatternFormatter : public Poco::PatternFormatter
{
public:
2018-01-17 18:10:38 +00:00
/// ADD_LAYER_TAG is needed only for Yandex.Metrika, that share part of ClickHouse code.
enum Options
{
ADD_NOTHING = 0,
ADD_LAYER_TAG = 1 << 0
};
2019-06-14 15:49:38 +00:00
OwnPatternFormatter(const Loggers * loggers_, Options options_ = ADD_NOTHING);
void format(const Poco::Message & msg, std::string & text) override;
void formatExtended(const DB::ExtendedLogMessage & msg_ext, std::string & text);
private:
2019-06-14 15:49:38 +00:00
const Loggers * loggers;
Options options;
};