Crate flexi_logger [−] [src]
An extended copy of env_logger, which can write the log to standard error or to a fresh file in a configurable folder and allows custom logline formats.
Usage
This crate is on crates.io and
can be used by adding flexi_logger
to the dependencies in your
project's Cargo.toml
.
[dependencies]
flexi_logger = "0.2"
and this to your crate root:
extern crate flexi_logger;
flexi_logger plugs into the logging facade given by the
log crate.
i.e., you use the log
macros to write log lines from your code.
In its initialization (see function init), you can
- decide whether you want to write your logs to stderr (like with env_logger), or to a file,
- configure the folder in which the log files are created,
- provide the log-level-specification, i.e., the decision which log lines really should be written out, programmatically (if you don't want to use the environment variable RUST_LOG)
- specify the line format for the log lines
(flexi_logger comes with two predefined variants for the log line format,default_format()
anddetailed_format()
, but you can easily create and use your own format function with the signaturefn(&LogRecord) -> String
)
Structs
FlexiLoggerError |
Describes all kinds of errors in the initialization of flexi_logger. |
LogConfig |
Allows influencing the behavior of flexi_logger. |
LogRecord |
The "payload" of a log message. |
Functions
default_format |
A logline-formatter that produces lines like |
detailed_format |
A logline-formatter that produces lines like |
init |
Initializes the flexi_logger to your needs, and the global logger with flexi_logger. |