aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Interpreters/TextLog.h
blob: bfeca324fde6b585e1bb9d1a205f4fd8885ef22e (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
49
50
51
52
53
54
55
#pragma once

#include <Interpreters/SystemLog.h>
#include <Core/NamesAndTypes.h>
#include <Core/NamesAndAliases.h>
#include <Poco/Message.h>

namespace DB
{

using Poco::Message;

struct TextLogElement
{
    time_t event_time{};
    Decimal64 event_time_microseconds{};

    String thread_name;
    UInt64 thread_id{};

    Message::Priority level = Message::PRIO_TRACE;

    String query_id;
    String logger_name;
    String message;

    String source_file;
    UInt64 source_line{};

    std::string_view message_format_string;

    static std::string name() { return "TextLog"; }
    static NamesAndTypesList getNamesAndTypes();
    static NamesAndAliases getNamesAndAliases() { return {}; }
    void appendToBlock(MutableColumns & columns) const;
    static const char * getCustomColumnList() { return nullptr; }
};

class TextLog : public SystemLog<TextLogElement>
{
public:
    using Queue = SystemLogQueue<TextLogElement>;

    explicit TextLog(ContextPtr context_, const SystemLogSettings & settings);

    static std::shared_ptr<Queue> getLogQueue(const SystemLogQueueSettings & settings)
    {
        static std::shared_ptr<Queue> queue = std::make_shared<Queue>(settings);
        return queue;
    }

    static consteval bool shouldTurnOffLogger() { return true; }
};

}