tlogger 0.1.2

A simple logging library with a neat style and customizablity.
Documentation

t_logger

A versatile and stylish logging library for Rust applications that provides both console output and file logging capabilities with customization options.

Features

  • ๐Ÿ“ Multiple log levels (info, warn, error, success, debug)
  • ๐ŸŽจ Full RGB color support with true color ANSI codes
  • ๐Ÿ“ฆ Box-style formatted messages
  • ๐Ÿ“… Automatic daily log file rotation
  • ๐Ÿ” Debug mode toggle
  • โฐ Timestamp integration
  • ๐Ÿ’พ File logging with clean (ANSI-stripped) output
  • ๐ŸŽฏ Fully customizable styling (colors, symbols, borders)

Installation

Add this to your Cargo.toml:

[dependencies]
tlogger = "0.1.1"

Or use the cargo add command:

cargo add tlogger

Usage

use tlogger::prelude::*;

#[cfg(test)]
#[test]
pub fn info() {
    use super::*;

    // init_logger("Logs").unwrap();

    customize_colors(Colors {
        info: ansi_rgb!(32, 80, 123),
        debug: ansi_rgb!(60, 200, 30),
        ..Default::default()
    });

    customize_symbols(Symbols {
        debug: "โŸ",
        ..Default::default()
    });

    customize_borders(Borders {
        ..Default::default()
    });

    info!("Server", "Starting");
    success!("Login", "User {} connected", "Alice");
    debug!("Processing", "Items in queue: {}", 42);
    warn!("Memory", "Usage at {}%", 85);
    error!("Database", "Connection failed");

    info_box!("System", "Your super secure super system is starting up.");
    warn_box!("Memory", "Memory usage is at {}%", 85);
    error_box!("Database", "Database connection failed");
    success_box!("Login", "User {} connected", "Alice");
    debug_box!("Processing", "Items in queue: {}", 42);
}

Log Levels

  • info!() / info_box!() - Cyan colored information messages
  • warn!() / warn_box!() - Yellow colored warning messages
  • error!() / error_box!() - Red colored error messages
  • success!() / success_box!() - Green colored success messages
  • debug!() / debug_box!() - Magenta colored debug messages

Debug Mode

Debug messages can be disabled in production while still being logged to file:

set_debug(false);  // Disables console output for debug messages

File Logging

When initialized, logs are automatically saved to files with the format YYYY-MM-DD.log in the specified directory. All ANSI color codes are automatically stripped from the file output for better readability.

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Example Output

โ„น 12:34:56.789 โ”‚ Server Starting up...
โœ” 12:34:56.790 โ”‚ Login User Alice connected
โš  12:34:56.791 โ”‚ Memory Usage at 85%
โœ– 12:34:56.792 โ”‚ Database Connection failed

Box Style Output:

โ•ญโ”€โœ”Loginโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โณ 12:29:47โ•ฎ
โ”‚ User Alice connected                                                    โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ