durylog
This crate adds logging to your projects or library.
After trying a lot of crates to make logging, I only found crates rich of futures but very complicate to use, or crates that are easy to use but log only on file or only on console.
I decided to write my own lib that aims to be easy to use with some usefull futures:
- Can log only on stdout, only on file or both.
- Very easy to start: install and use immediately.
- Short API names.
- It implements log crate so you can use Rust library logging macros.
Add to project:
In file cargo.toml add:
[]
= "0.1.0"
Getting Start
There are 2 way for use this crate:
- Directly create object:
let durylog=DLog::new();and use likedurylog.d("Log message"); - Initialize logger:
DLog::new().init_logger().ok();and use with log macro likedebug!("Log message");
Read documentation and examples.
Output (on console and/or file) for default settings is like:
2023/01/02 18.01.27 : DEBUG : Debug message
First tag is datetime stamp, second tag is level name followed by log message tag
Examples:
Directly usage with default settings:
use DLog;
This will log on stdout without colors.
Directly usage with custom settings:
use DLog;
This will log on stdout with colors, different formatting for timestamp and different tags separator and in file durylog-custom.log are added same log lines as in console.
Macros usage with default settings:
use ;
This will log on stdout without colors.
Macros usage with custom settings:
use ;
This will log on stdout with colors, different formatting for timestamp and different tags separator and in file log-custom.log are added same log lines as in console.