Crates.io | layla-log |
lib.rs | layla-log |
version | 0.2.8 |
source | src |
created_at | 2024-03-31 13:07:47.457268 |
updated_at | 2024-04-26 05:45:56.437331 |
description | A simple logger library. |
homepage | |
repository | |
max_upload_size | |
id | 1191664 |
size | 16,459 |
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).
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.
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.