#log #testing #text #utility

plog

A modular pretty logger written for Rust programs

19 releases

0.2.16 Nov 5, 2022
0.2.15 Nov 5, 2022
0.2.13 Jun 9, 2022
0.2.12 May 1, 2022
0.1.2 Mar 27, 2022

#241 in Debugging

Download history 16/week @ 2023-11-05 1/week @ 2023-11-12 28/week @ 2023-11-19 69/week @ 2023-11-26 43/week @ 2023-12-03 19/week @ 2023-12-10 10/week @ 2023-12-17 43/week @ 2023-12-24 34/week @ 2023-12-31 15/week @ 2024-01-07 23/week @ 2024-01-14 20/week @ 2024-01-21 43/week @ 2024-01-28 6/week @ 2024-02-04 60/week @ 2024-02-11 404/week @ 2024-02-18

513 downloads per month

MIT license

20KB
330 lines

plog

A pretty logger written for Rust programs.

A library to log applications just using macros, includes initially five levels: debug!, info!, ok!, warn! and error!, each one distributed as a macro:

use plog::{info, ok};
use std::{thread, time::Duration};

fn main() {
    let threads: Vec<_> = (0..=10)
        .map(|id| {
            info!("Creating thread {id}");
            thread::spawn(move || {
                thread::sleep(Duration::from_millis(1000));
                ok!("Thread {id} terminated");
            })
        })
        .collect();
        
    threads.into_iter().for_each(|thr| thr.join().unwrap());
}

features

Due to the focus on optimization, every functionality from the lib (except log macros) is offered by features. Plog contains the following features:

feature description additional dependence why
local_date Include local date on the log, formatted as %Y-%M-%D chrono (branch time-0.3) Get local date information and formatting
local_time Similar to local_date, but logs the time with %H:%M:%S chrono (branch time-0.3) Get local time information and formatting
context Include the line and file that has required the log none
colored Use escape sequences to print stylized text crossterm Crossplatform escape sequences parser
persistent Add a persistent log handled by LOG_FILEPATH environment variable, saving each log on the pointed file parking_lot (until 0.2.14) const_mutex for stable Rust and optimizations
impls Implements log and show_<variant> for Option<T> and Result<T, U> none

plans

  • Split date and time into two features
  • Include logging methods to Option and Result
  • Optimize code readability
  • Include benchmarks
  • Create documentation

Dependencies

~0–9MB
~59K SLoC