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
// Copyright 2021 Twitter, Inc.
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0

use core::time::Duration;
use ringlog::*;

fn main() {
    let log = LogBuilder::new()
        .output(Box::new(Stdout::new()))
        .build()
        .expect("failed to initialize log");

    let mut drain = log.start();

    std::thread::spawn(move || loop {
        let _ = drain.flush();
        std::thread::sleep(Duration::from_millis(100));
    });

    error!("error");
    warn!("warning");
    info!("info");
    debug!("debug");
    trace!("trace");

    std::thread::sleep(Duration::from_millis(1000));
}