ptero/cli/
writer.rs

1use atty::Stream;
2use colored::Colorize;
3use log::{error, info, warn};
4
5pub struct Writer;
6
7#[cfg(not(tarpaulin_include))]
8impl Writer {
9    pub fn info(data: &str) {
10        info!("{}", data);
11        if atty::is(Stream::Stdout) {
12            println!("{}", data.green());
13        }
14    }        
15    
16    pub fn print(data: &str) {
17        if atty::is(Stream::Stdout) {
18            println!("{}", data);
19        }
20    }    
21    
22    pub fn error(data: &str) {
23        error!("{}", data);
24        if atty::is(Stream::Stderr) {
25            eprintln!("{}", data.red().bold());
26        }
27    }    
28
29    pub fn warn(data: &str) {
30        warn!("{}", data);
31        if atty::is(Stream::Stderr) {
32            eprintln!("{}", data.yellow());
33        }
34    }
35}