aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Client/InternalTextLogs.h
blob: 0690211fd246d3958c352a360b4005a5df88c541 (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
#pragma once
#include <IO/WriteBuffer.h>
#include <Core/Block.h>


namespace DB
{

/// Prints internal server logs or profile events with colored output (if requested).
/// NOTE: IRowOutputFormat does not suite well for this case
class InternalTextLogs
{
public:
    InternalTextLogs(WriteBuffer & buf_out, bool color_) : wb(buf_out), color(color_) {}

    /// Print internal server logs
    ///
    /// Input blocks have to have the same structure as SystemLogsQueue::getSampleBlock():
    /// - event_time
    /// - event_time_microseconds
    /// - host_name
    /// - query_id
    /// - thread_id
    /// - priority
    /// - source
    /// - text
    void writeLogs(const Block & block);
    /// Print profile events.
    ///
    /// Block:
    /// - host_name
    /// - current_time
    /// - thread_id
    /// - type
    /// - name
    /// - value
    ///
    /// See also TCPHandler::sendProfileEvents() for block columns.
    void writeProfileEvents(const Block & block);

    void flush()
    {
        wb.next();
    }

private:
    WriteBuffer & wb;
    bool color;
};

}