demo_single/
demo-single.rs

1// Copyright 2021 Twitter, Inc.
2// Licensed under the Apache License, Version 2.0
3// http://www.apache.org/licenses/LICENSE-2.0
4
5use core::time::Duration;
6use ringlog::*;
7
8fn main() {
9    let log = LogBuilder::new()
10        .output(Box::new(Stdout::new()))
11        .build()
12        .expect("failed to initialize log");
13
14    let mut drain = log.start();
15
16    std::thread::spawn(move || loop {
17        let _ = drain.flush();
18        std::thread::sleep(Duration::from_millis(100));
19    });
20
21    error!("error");
22    warn!("warning");
23    info!("info");
24    debug!("debug");
25    trace!("trace");
26
27    std::thread::sleep(Duration::from_millis(1000));
28}