aboutsummaryrefslogtreecommitdiff
path: root/src/rt/rust_log.h
blob: 29c85e7098f2fd77ab3014c22aec7d94a238104d (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
56
57
58
59
60
61
62
63
64
65
66
#ifndef RUST_LOG_H
#define RUST_LOG_H

class rust_dom;
class rust_task;



class rust_log {

public:
    rust_log(rust_srv *srv, rust_dom *dom);
    virtual ~rust_log();

    enum ansi_color {
        WHITE,
        RED,
        LIGHTRED,
        GREEN,
        LIGHTGREEN,
        YELLOW,
        LIGHTYELLOW,
        BLUE,
        LIGHTBLUE,
        MAGENTA,
        LIGHTMAGENTA,
        TEAL,
        LIGHTTEAL
    };

    enum log_type {
        ERR = 0x1,
        MEM = 0x2,
        COMM = 0x4,
        TASK = 0x8,
        DOM = 0x10,
        ULOG = 0x20,
        TRACE = 0x40,
        DWARF = 0x80,
        CACHE = 0x100,
        UPCALL = 0x200,
        TIMER = 0x400,
        GC = 0x800,
        ALL = 0xffffffff
    };

    void indent();
    void outdent();
    void reset_indent(uint32_t indent);
    void trace_ln(uint32_t thread_id, char *prefix, char *message);
    void trace_ln(rust_task *task, uint32_t type_bits, char *message);
    void trace_ln(rust_task *task, ansi_color color,
                  uint32_t type_bits, char *message);
    bool is_tracing(uint32_t type_bits);

private:
    rust_srv *_srv;
    rust_dom *_dom;
    uint32_t _type_bit_mask;
    bool _use_labels;
    bool _use_colors;
    uint32_t _indent;
    void trace_ln(rust_task *task, char *message);
};

#endif /* RUST_LOG_H */