lumbermill 0.2.0

Simple structured logging
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::log::{Log, LogFormat};
use std::io::{self, stdout, Stdout};

#[derive(Debug)]
pub struct StdoutLogger {
  stdout: Stdout,
}

impl StdoutLogger {
  pub fn new() -> Self {
    Self { stdout: stdout() }
  }

  pub fn log(&self, log: &Log, format: &LogFormat) -> io::Result<()> {
    let writer = &mut self.stdout.lock();
    log.write(writer, format)
  }
}