Tlogger
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
- ๐ Configurable log file intervals (hourly, every 3 hours, every 6 hours, ..., Daily)
- ๐ 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:
[]
= "0.1.3"
Or use the cargo add command:
Usage
use *;
Log Levels
info!()/info_box!()- Cyan colored information messageswarn!()/warn_box!()- Yellow colored warning messageserror!()/error_box!()- Red colored error messagessuccess!()/success_box!()- Green colored success messagesdebug!()/debug_box!()- Magenta colored debug messages
Log Intervals
Configure how frequently new log files are created:
LogInterval::OneHour- New file every hour (e.g.,2024-02-20-14h-15h.log)LogInterval::ThreeHour- Every 3 hours (e.g.,2024-02-20-12h-15h.log)LogInterval::SixHour- Every 6 hours (e.g.,2024-02-20-12h-18h.log)LogInterval::NineHour- Every 9 hours (e.g.,2024-02-20-09h-18h.log)LogInterval::TwelveHour- Every 12 hours (e.g.,2024-02-20-12h-00h.log)LogInterval::OneDay- One file per day (e.g.,2024-02-20-00h-24h.log)
Debug Mode
Debug messages can be disabled in production while still being logged to file:
set_debug; // Disables console output for debug messages
File Logging
When initialized, logs are automatically saved to files based on the specified interval. All ANSI color codes are automatically stripped from the file output for better readability.
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 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ