2 releases

Uses new Rust 2024

0.1.1 Sep 3, 2025
0.1.0 Aug 14, 2025

#887 in Debugging

Download history 16/week @ 2025-08-18 2/week @ 2025-08-25 152/week @ 2025-09-01 82/week @ 2025-09-08 57/week @ 2025-09-15 63/week @ 2025-09-22 69/week @ 2025-09-29 47/week @ 2025-10-06 80/week @ 2025-10-13 91/week @ 2025-10-20 56/week @ 2025-10-27 58/week @ 2025-11-03 57/week @ 2025-11-10 52/week @ 2025-11-17 51/week @ 2025-11-24 45/week @ 2025-12-01

207 downloads per month
Used in 11 crates

MIT license

7KB
63 lines

Fancy Log

A simple and customizable logging library for Rust, providing colored console output with timestamped log messages and configurable log levels.

Features

  • Log Levels: Supports Error, Warn, Info, and Debug log levels.
  • Colored Output: Logs are displayed in different colors based on the log level (e.g., red for errors, yellow for warnings).
  • Timestamps: Each log message includes a timestamp in HH:MM:SS format.
  • Thread-Safe: Uses a global, thread-safe log level configuration.
  • Customizable: Easily set the minimum log level to filter messages.

Installation

Add the following to your Cargo.toml:

[dependencies]
fancy-log = "0.1.0"

Usage

Basic Example

use fancy_log::{log, set_log_level, LogLevel};

fn main() {
    // Set the minimum log level to Info
    set_log_level(LogLevel::Info);

    // Log messages
    log(LogLevel::Info, "This is an info message");
    log(LogLevel::Warn, "This is a warning message");
    log(LogLevel::Error, "This is an error message");
    log(LogLevel::Debug, "This debug message will not be shown");
}

Setting Log Level

You can configure the log level to filter out messages below a certain threshold:

use fancy_log::{set_log_level, LogLevel};

// Set log level to Debug to show all messages
set_log_level(LogLevel::Debug);

Log Output

  • Error: Printed to stderr in red.
  • Warn: Printed to stderr in yellow.
  • Info: Printed to stdout in white.
  • Debug: Printed to stdout in blue.

Example output:

12:34:56 This is an info message
12:34:56 This is a warning message
12:34:56 This is an error message

Dependencies

  • chrono = "0.4": For timestamp formatting.
  • once_cell = "1.21": For thread-safe global log level storage.
  • termcolor = "1.4.1": For colored console output.
  • serde = { version = "1", features = ["derive"] }: For log level deserialization.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Dependencies

~1.3–4MB
~75K SLoC