Crates.io | simple_file_logger |
lib.rs | simple_file_logger |
version | 0.4.1 |
source | src |
created_at | 2022-09-04 20:11:00.319415 |
updated_at | 2024-05-09 13:18:35.806429 |
description | A simple file logger for Rust |
homepage | |
repository | https://github.com/mendelsshop/simple_file_logger |
max_upload_size | |
id | 658428 |
size | 11,769 |
A simple file logger for rust.
Very basic setup, just provide an app name and an optional log level.
use simple_file_logger::{init_logger, LogLevel};
use log::info;
fn main() {
init_logger("my_app", Loglevel::Info).unwrap();
info!("Hello, world!");
}
or if you want to use the default log level (and save typing around 15 characters):
use simple_file_logger::init_logger;
fn main() {
init_logger!("my_app").unwrap();
info!("Hello, world!");
}
The log levels are: trace
, debug
, info
, warn
, error
.
The log file is located:
OS | Path | Example |
---|---|---|
Windows | %FOLDERID_LocalAppData%\program_name\log\program_nametime_stamp.log | C:\Users\username\AppData\Local\program_name\log\program_name_2020-05-01T12-34-56.log |
Linux | $XDG_DATA_HOME/program_name/log/program_name_time_stamp.log | /home/username/.local/share/program_name/log/program_name_2020-05-01T12-34-56.log |
macOS | $HOME/Library/Application Support/program_name/log/program_nametime_stamp.log | Users/username/Library/Application Support/program_name/log/program_name_2020-05-01T12-34-56.log |