# 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`:
```toml
[dependencies]
fancy-log = "0.1.0"
```
## Usage
### Basic Example
```rust
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:
```rust
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.