2016-10-04 09:58:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include <Poco/PatternFormatter.h>
|
2023-02-27 13:38:15 +00:00
|
|
|
#include <Common/DateLUT.h>
|
2019-06-14 14:00:37 +00:00
|
|
|
#include "ExtendedLogChannel.h"
|
2017-02-07 16:37:56 +00:00
|
|
|
|
2016-10-04 09:58:38 +00:00
|
|
|
|
2019-06-20 07:17:21 +00:00
|
|
|
/** Format log messages own way.
|
|
|
|
* We can't obtain some details using Poco::PatternFormatter.
|
2016-10-04 09:58:38 +00:00
|
|
|
*
|
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)
|
2016-10-04 09:58:38 +00:00
|
|
|
*
|
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
|
2016-10-04 09:58:38 +00:00
|
|
|
*
|
2019-06-20 07:17:21 +00:00
|
|
|
* Also it's made a bit more efficient (unimportant).
|
2016-10-04 09:58:38 +00:00
|
|
|
*/
|
2017-04-26 14:31:25 +00:00
|
|
|
|
2019-06-14 14:00:37 +00:00
|
|
|
class Loggers;
|
2017-04-26 14:31:25 +00:00
|
|
|
|
2016-10-04 09:58:38 +00:00
|
|
|
class OwnPatternFormatter : public Poco::PatternFormatter
|
|
|
|
{
|
|
|
|
public:
|
2024-02-29 14:56:33 +00:00
|
|
|
explicit OwnPatternFormatter(bool color_ = false);
|
2017-02-06 14:57:47 +00:00
|
|
|
|
2017-04-26 14:31:25 +00:00
|
|
|
void format(const Poco::Message & msg, std::string & text) override;
|
2022-07-28 16:20:28 +00:00
|
|
|
virtual void formatExtended(const DB::ExtendedLogMessage & msg_ext, std::string & text) const;
|
2016-10-04 09:58:38 +00:00
|
|
|
|
|
|
|
private:
|
2023-04-12 10:47:05 +00:00
|
|
|
const DateLUTImpl & server_timezone = DateLUT::serverTimezoneInstance();
|
2020-02-03 02:33:31 +00:00
|
|
|
bool color;
|
2016-10-04 09:58:38 +00:00
|
|
|
};
|