simple/
simple.rs

1/*!
2Using `fil_logger`.
3
4By default the `fil_logger` doesn't log anything. You can change this by setting the `RUST_LOG`
5environment variable to another level. This will show log output on stderr. Example:
6
7```console
8$ RUST_LOG=info cargo run --example simple
9    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
10     Running `target/debug/examples/simple`
112019-11-11T20:26:09.448 INFO simple > logging on into level
122019-11-11T20:26:09.448 WARN simple > logging on warn level
132019-11-11T20:26:09.448 ERROR simple > logging on error level
14```
15
16It is also possible to ouput the log as JSON. Simply set the `GOLOG_LOG_FMT` environment variable
17to `json`. It is a bit more verbose and also contains the line file and line number of the log
18call:
19
20```console
21$ GOLOG_LOG_FMT=json RUST_LOG=info cargo run --example simple
22    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
23     Running `target/debug/examples/simple`
24{"level":"info","ts":"2021-06-17T10:17:57.605+0200","logger":"simple","caller":"examples/simple.rs:38","msg":"logging on into level"}
25{"level":"warn","ts":"2021-06-17T10:17:57.605+0200","logger":"simple","caller":"examples/simple.rs:39","msg":"logging on warn level"}
26{"level":"error","ts":"2021-06-17T10:17:57.605+0200","logger":"simple","caller":"examples/simple.rs:40","msg":"logging on error level"}
27{"level":"info","ts":"2021-06-17T10:17:57.605+0200","logger":"simple","caller":"examples/simple.rs:42","msg":"logging string with json: {\"hello\": true}"}
28```
29*/
30
31use fil_logger;
32use log::{debug, error, info, trace, warn};
33
34fn main() {
35    fil_logger::init();
36
37    trace!("logging on trace level");
38    debug!("logging on debug level");
39    info!("logging on into level");
40    warn!("logging on warn level");
41    error!("logging on error level");
42
43    info!(r#"logging string with json: {{"hello": true}}"#);
44}