8 releases

0.1.7 Oct 11, 2022
0.1.6 Apr 25, 2022
0.1.4 Mar 31, 2022
0.1.3 Jun 18, 2021
0.1.0 Nov 14, 2019

#115 in Debugging

Download history 745/week @ 2022-08-19 654/week @ 2022-08-26 535/week @ 2022-09-02 684/week @ 2022-09-09 540/week @ 2022-09-16 617/week @ 2022-09-23 666/week @ 2022-09-30 996/week @ 2022-10-07 896/week @ 2022-10-14 652/week @ 2022-10-21 759/week @ 2022-10-28 562/week @ 2022-11-04 615/week @ 2022-11-11 554/week @ 2022-11-18 649/week @ 2022-11-25 377/week @ 2022-12-02

2,283 downloads per month
Used in 11 crates (5 directly)

MIT/Apache

13KB
130 lines

A logging library used by Filecoin

This crate is used to make sure that all Filecoin related crates log in the same format.

By default the fil_logger doesn't log anything. You can change this by setting the RUST_LOG environment variable to another level. This will show log output on stderr. Example:

$ RUST_LOG=info cargo run --example simple
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `target/debug/examples/simple`
2019-11-11T20:26:09.448 INFO simple > logging on into level
2019-11-11T20:26:09.448 WARN simple > logging on warn level
2019-11-11T20:26:09.448 ERROR simple > logging on error level

It is also possible to ouput the log as JSON. Simply set the GOLOG_LOG_FMT environment variable to json. It is a bit more verbose and also contains the line file and line number of the log call:

$ GOLOG_LOG_FMT=json RUST_LOG=info cargo run --example simple
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/examples/simple`
{"level":"info","ts":"2019-11-11T20:59:31.168+0100","logger":"simple","caller":"examples/simple.rs:30","msg":"logging on into level"}
{"level":"warn","ts":"2019-11-11T20:59:31.168+0100","logger":"simple","caller":"examples/simple.rs:31","msg":"logging on warn level"}
{"level":"error","ts":"2019-11-11T20:59:31.168+0100","logger":"simple","caller":"examples/simple.rs:32","msg":"logging on error level"}

Example

use fil_logger;
use log::{debug, error, info, trace, warn};

fn main() {
    fil_logger::init();

    trace!("logging on trace level");
    debug!("logging on debug level");
    info!("logging on into level");
    warn!("logging on warn level");
    error!("logging on error level");
}

License

The Filecoin Project is dual-licensed under Apache 2.0 and MIT terms:

Dependencies

~1.5–2.3MB
~43K SLoC