loggify
A small and simple log implementation that I use in my rust projects.
Install
Just add
[]
= "0.4.8"
= "1"
to your Cargo.toml
Usage
All examples can be found in the examples
directory.
Basic
The simpliest way is just to call init
.
The default log level is Info
, so that debug and trace messages are not shown.
//! examples/01_basic.rs
//! # Basic usage for the logger
use ;
use Loggify;
/// The default level is INFO. So debug and trace outputs are oppressed
With log level
//! examples/02_log_level.rs
//! Example for initializing the logger with a log level
use ;
use Loggify;
/// Same as the basic example with the difference that
/// the logger is intialized with the debug log level.
Log builder
//! examples/03_builder.rs
//! Example for initializing the logger with the LogBuilder
use ;
use LogBuilder;
/// The `LogBuilder` is used to set more logger options
/// This example will change the log level to Trace
/// and the printed time format to time only
Disable color output
You can either programmatically disable color output or use the env LOGGIFY_COLOR
variable.
To disable it using the env variable use LOGGIFY_COLOR=false
.
If the value of the env variable cannot be parsed as a boolean value, the logger silently defaults to a colored output.
See the code example for programmatically disabling colored output.
//! examples/05_builder.rs
//! Example for initializing the logger with the LogBuilder
use ;
use LogBuilder;
/// The `LogBuilder` is used to set more logger options
/// This example will disable the colored output
Exclude targets from log
//! examples/04_exclude.rs
//! Example for excluding log targets from getting logged
use ;
use LogBuilder;
/// Exmple on how to exclude specific log targets