Skip to content

AltIsBacc/loglet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

loglet

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

Installation

Add to your Cargo.toml:

[dependencies]
loglet = "0.0.2"

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

About

A lightweight zero-heap logging library in Rust!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages