8 releases
0.2.8 | Apr 26, 2024 |
---|---|
0.2.7 | Apr 25, 2024 |
0.1.1 |
|
0.1.0 |
|
#667 in Debugging
69 downloads per month
15KB
276 lines
Layla-log
A simple logger library. This library provides a simple log writer and simple log level control. It can be used to write logs in a program. The logs can be written to the aimed dictionary. The log level can be set to different levels (Error, Warn, Debug, and Info).
Usage
This can be initialized by using default setting, only the path of the aim dictionary is needed.
use layla_log::*;
fn main() {
default_init("path/to/log/directory/");
clean_log(); // This will clean the log file.
error!("error message.");
warn!("warn message.");
info!("info message.");
debug!("debug message.");
trace!("trace message.");
}
And this will be the output in the log file.
{time} ERROR error message.
{time} WARN warn message.
{time} DEBUG debug message.
{time} INFO info message.
{time} TRACE trace message.
(Because the default log level is TRACE, so all the log will be recorded.)
And the time format is "yyyy-MM-dd HH:mm:ss.SSS". (The millisecond is included.)
It also provides a function for personal initializing, the following can be decided.
- The path of the aim dictionary.
- Maximum number of log in a single file. (0 as inf.)
- The restriction of the log level.
- Time zone.
- Show detailed time or not.
use layla_log::*;
fn main() {
init("path/to/log/directory/", Some(200), Some(LogLevel::Debug) , 0, false);
clean_log();
error!("error message.");
warn!("warn message.");
info!("info message.");
debug!("debug message.");
trace!("trace message.");
}
And this will be the output.
{time} ERROR error message.
{time} WARN warn message.
{time} INFO info message.
{time} DEBUG debug message.
Dependencies
~1MB
~18K SLoC