summaryrefslogtreecommitdiff
path: root/racer-tracer/src/terminal.rs
blob: 48eb59995e082e359cc11ad94f570ca1f9d6b759 (plain)
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
use console::Term;
use slog::Logger;

pub struct Terminal {
    pub logger: Logger,
    pub terminal: Term,
}

impl Terminal {
    pub fn new(logger: Logger) -> Self {
        Self {
            logger,
            terminal: Term::stdout(),
        }
    }
}

macro_rules! write_term {
    ($term:expr, $text:expr) => {{
        if let Err(e) = $term.terminal.write_line($text) {
            debug!($term.logger, "Failed to write to terminal: {}", e)
        }
    }};
}

pub(crate) use write_term;