Expand description
The logging level can be changed by the RUST_LOG environment variable just like
env_logger.
§Example
use log::{trace, debug, info, warn, error};
fil_logger::init();
trace!("some tracing");
debug!("debug information");
info!("normal information");
warn!("a warning");
error!("error!");The default output looks like this (with log level debug):
2019-11-11T21:04:25.685 DEBUG simple > debug information
2019-11-11T21:04:25.685 INFO simple > normal information
2019-11-11T21:04:25.685 WARN simple > a warning
2019-11-11T21:04:25.685 ERROR simple > error!It is also possible to log as JSON, which is more verbose and contains the filename and line
number as additional information. To enable it, set the environment variable
GOLOG_LOG_FMT=json:
{“level”:“debug”,“ts”:“2019-11-11T21:06:45.401+0100”,“logger”:“simple”,“caller”:“examples/simple.rs:37”,“,sg”:“debug information”} {“level”:“info”,“ts”:“2019-11-11T21:06:45.401+0100”,“logger”:“simple”,“caller”:“examples/simple.rs:38”,“msg”:“//! normal information”} {“level”:“warn”,“ts”:“2019-11-11T21:06:45.401+0100”,“logger”:“simple”,“caller”:“examples/simple.rs:39”,“msg”:“//! a warning”} {“level”:“error”,“ts”:“2019-11-11T21:06:45.401+0100”,“logger”:“simple”,“caller”:“examples/simple.rs:40”,“msg”:“error!”}
Structs§
- Single
File Writer - A
LogWriterthat accepts an openFile
Functions§
- color_
logger_ format - Logs with color, contains the same information as the pretty_env_logger.
- go_
log_ json_ format - Logs in the same JSON format as IPFS go-log does.
- init
- Initializes a new logger. It logs to stderr.
- init_
with_ file - initializes a new logger that logs to an already opened
std::fs::File. - maybe_
init - Maybe initializes a new logger. It logs to stderr.
- nocolor_
logger_ format - Logs without color, contains the same information as the pretty_env_logger.