7 unstable releases

0.4.1 May 9, 2024
0.4.0 May 8, 2024
0.3.1 Dec 2, 2022
0.2.0 Sep 6, 2022
0.1.1 Sep 4, 2022

#707 in Debugging

Download history 35/week @ 2024-08-19 7/week @ 2024-08-26 30/week @ 2024-09-02 13/week @ 2024-09-16 4/week @ 2024-09-23 80/week @ 2024-09-30 14/week @ 2024-10-07 1/week @ 2024-10-14 14/week @ 2024-10-28 30/week @ 2024-11-11 6/week @ 2024-11-18 19/week @ 2024-11-25 15/week @ 2024-12-02

70 downloads per month
Used in 6 crates (4 directly)

MIT license

9KB
86 lines

crates.io Crates.io docs.rs

Simple File Logger

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

Optional features

  • clap: enable clap parsing for LogLevel, Uses the ValueEnum proc-macro.
  • serde: enable serde serialization and deserialization on LogLevel.

Dependencies

~1.8–10MB
~97K SLoC