Crate plog

source ·
Expand description

A modular pretty logger for Rust

Created with the philosophy to be minimum but extensible everything (except core) is a feature, every configuration is defined in compiler-level to minimal run-time overhead.

Usage

Simplest as possible, works like a std::println! (more exatcly as a std::eprintln!):

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

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

All the available features are listed here

Modules

Core of the library. Contains the front-end to plog::log, formating arguments and applying features defined at compile-time

Macros

A debugging logger, just will compile the log message when debug_assert is enabled
An error logger, the highest importancy level, for things that will affect the program use
An info logger, the lowest importancy level
Log formatter, apply every formating feature enabled:
Success logger, for things that is working. The “release version” of plog::debug! Also works on debug_assert
A warn logger, for things that don’t affect the program flow

Functions

Log handler Checks the enabled features and write to specified streams persistent enable write to a file colored enable colored output to terminal