Ftail
Ftail is simple logging implementation for the log crate with support for multiple drivers.
Usage
Add the following dependencies to your Cargo.toml file:
[]
= "0.1"
Add the following code to your main.rs or lib.rs file:
use Ftail;
use LevelFilter;
new
.console
.daily_file
.init?;
// log messages anywhere in your code
trace!;
debug!;
info!;
warn!;
error!;
You can set the following configuration options:
.datetime_format("%Y-%m-%d %H:%M:%S.3f")to set the datetime format.timezone(ftail::Tz::UTC)to set the timezone [requires featuretimezone]
Drivers
Console
Logs to the standard output without any formatting.
The stdout driver takes the following parameters:
level: the minumum log level to log
new
.console
.init?;
Formatted Console
Logs to the standard output with formatted and colored output.
The console driver takes the following parameters:
level: the minumum log level to log
new
.formatted_console
.init?;
Single file
Logs to the single log file logs/demo.log.
The single_file driver takes the following parameters:
path: the path to the log fileappend: whether to append to the log file or overwrite itlevel: the minumum log level to log
new
.single_file
.init?;
Daily file
Logs to a daily log file in the logs directory. The log files have the following format: YYYY-MM-DD.log.
The daily_file driver takes the following parameters:
dir: the directory to store the log fileslevel: the minumum log level to log
new
.daily_file
.init?;
Custom driver
Create your own log driver.
new
.custom
.datetime_format
.init?;
// the custom logger implementation