tcplane/utils/
print.rs

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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#[macro_export]
macro_rules! print_success {
    ($($data:expr),*) => {{
        let binding: String = format!("[{} => success]",current_time());
        let mut time_output_builder: OutputBuilder<'_> = OutputBuilder::new();
        let time_output: Output<'_> = time_output_builder
            .text(&binding)
            .blod(true)
            .bg_color(ColorType::Rgb(0,255,0))
            .color(ColorType::Color256(0xffffff))
            .build();
        let mut output_list_builder = OutputListBuilder::new();
        output_list_builder.add(time_output);
        $(
            let text = $data.to_string();
            let mut text_output_builder: OutputBuilder<'_> = OutputBuilder::new();
            let text_output: Output<'_> = text_output_builder
                .text(&text)
                .blod(true)
                .color(ColorType::Rgb(0,255,0))
                .endl(false)
                .build();
            output_list_builder.add(text_output);
        )*
        output_list_builder.run();
    }};
}

#[macro_export]
macro_rules! print_warning {
    ($($data:expr),*) => {{
        let binding: String = format!("[{} => warning]",current_time());
        let mut time_output_builder: OutputBuilder<'_> = OutputBuilder::new();
        let time_output: Output<'_> = time_output_builder
            .text(&binding)
            .blod(true)
            .bg_color(ColorType::Rgb(255, 255, 0))
            .color(ColorType::Color256(0xffffff))
            .build();
        let mut output_list_builder = OutputListBuilder::new();
        output_list_builder.add(time_output);
        $(
            let text = $data.to_string();
            let mut text_output_builder: OutputBuilder<'_> = OutputBuilder::new();
            let text_output: Output<'_> = text_output_builder
                .text(&text)
                .blod(true)
                .color(ColorType::Rgb(255, 255, 0))
                .endl(false)
                .build();
            output_list_builder.add(text_output);
        )*
        output_list_builder.run();
    }};
}

#[macro_export]
macro_rules! print_danger {
    ($($data:expr),*) => {{
        let binding: String = format!("[{} => danger]",current_time());
        let mut time_output_builder: OutputBuilder<'_> = OutputBuilder::new();
        let time_output: Output<'_> = time_output_builder
            .text(&binding)
            .blod(true)
            .bg_color(ColorType::Rgb(255,0,0))
            .color(ColorType::Color256(0xffffff))
            .build();
        let mut output_list_builder = OutputListBuilder::new();
        output_list_builder.add(time_output);
        $(
            let text = $data.to_string();
            let mut text_output_builder: OutputBuilder<'_> = OutputBuilder::new();
            let text_output: Output<'_> = text_output_builder
                .text(&text)
                .blod(true)
                .color(ColorType::Rgb(255,0,0))
                .endl(false)
                .build();
            output_list_builder.add(text_output);
        )*
        output_list_builder.run();
    }};
}