[−][src]Crate fil_logger
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+01:00","logger":"simple","caller":"examples/simple.rs:37",",sg":"debug information"}" {"level":"info","ts":"2019-11-11T21:06:45.401+01:00","logger":"simple","caller":"examples/simple.rs:38","msg":"//! normal information"}" {"level":"warn","ts":"2019-11-11T21:06:45.401+01:00","logger":"simple","caller":"examples/simple.rs:39","msg":"//! a warning"}" {"level":"error","ts":"2019-11-11T21:06:45.401+01:00","logger":"simple","caller":"examples/simple.rs:40","msg":"error!"}"
Structs
SingleFileWriter | A |
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 |
nocolor_logger_format | Logs without color, contains the same information as the pretty_env_logger. |