loglet 0.0.1

A lightweight zero-heap logging library
Documentation
  • Coverage
  • 0%
    0 out of 18 items documented0 out of 11 items with examples
  • Size
  • Source code size: 10.79 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 447.89 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • AltIsBacc/loglet
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • AltIsBacc

loglet

A minimal, zero-heap Rust logging library for CLI applications.

Installation

Add to your Cargo.toml:

[dependencies]
loglet = "0.0.1"

Or via the command line:

cargo add loglet

Features

  • Zero heap allocations (uses fmt::Arguments throughout)
  • Coloured output via owo-colors
  • Tagged log entries
  • Custom log levels
  • Debug logs compiled away in release builds
  • Writes errors to stderr, everything else to stdout

Usage

From examples/basic_usage.rs:

use loglet::{info, warn, error, debug};

fn main() {
    info!("Starting application.");

    let user = "Alice";
    let attempts = 3;
    warn!("Failed login by '{}' (attempt #{})", user, attempts);

    error!("Database connection timed out!");

    debug!("Hidden in release builds.");

    // Tagged
    info!(tag: "auth", "User '{}' logged in.", user);
    warn!(tag: "db", "Connection pool running low.");
    error!(tag: "network", "Host unreachable after {} retries.", 5);
}

Check out the examples/ folder for more.

Default Log Levels

Macro Prefix Stream Color
info! I stdout Green
warn! W stdout Yellow
error! E stderr Red
debug! D stdout Cyan

Custom levels are also supported (see examples/custom_level.rs)

Examples

Clone the repo first:

git clone https://github.com/AltIsBacc/loglet
cd loglet

Then run any example:

cargo run --example basic_usage
cargo run --example custom_level

License

MIT