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
29
30
31
32
33
34
35
#[macro_use] extern crate rust_util;

use rust_util::{XResult, SimpleError};
use rust_util::util_msg::set_logger_std_out;

// cargo run --example log
fn main() -> XResult<()> {
    std::env::set_var("LOGGER_LEVEL", "*");
    println!(r##"env LOGGER_LEVEL set to:
debug or *
info or ? -- default
ok or #
warn or !
error or ^"##);

    debugging!("Hello {}", "world!");
    information!("Hello {}", "world!");
    success!("Hello {}", "world!");
    warning!("Hello {}", "world!");
    failure!("Hello {}", "world!");

    println!("{:?}", test_opt_result());

    set_logger_std_out(false);
    information!("Std err!");
    warning!("Std err!");
    set_logger_std_out(true);

    simple_error!("helloworld {}", 1)
}

fn test_opt_result() -> XResult<()> {
    let a = Err(SimpleError::new("test".into()));
    opt_result!(a, "error: {}")
}