2 releases
Uses new Rust 2024
new 0.0.2 | Mar 19, 2025 |
---|---|
0.0.1 | Mar 18, 2025 |
#813 in Debugging
148 downloads per month
Used in madruga
7KB
96 lines
Collecting workspace information
Black
A simple logging library implemented in Rust.
About
The Black project is a simple logging library that allows you to record log messages at different levels (DEBUG, INFO, WARN, EVENT, and ERROR) to a file. Logging is performed asynchronously and in a thread-safe manner using Arc<Mutex<File>>
.
Features
- Supports multiple log levels:
- DEBUG
- INFO
- WARN
- EVENT
- ERROR
- Provides a simple and intuitive interface for event logging.
Project Structure
- Cargo.toml – Project configuration and dependencies.
- src/lib.rs – Implementation of the Black library.
- examples/main.rs – Example usage of the library.
Usage Example
Below is an example application that uses Black to record logs:
use anyhow::Result;
use black::BlackBox;
fn main() -> Result<()> {
let logger = BlackBox::new("blackbox.log")?;
logger.log_event("Application started")?;
logger.log_error("Error: could not connect to the database")?;
logger.log_event("Data processing complete")?;
Ok(())
}
Building and Running
To build the project, run:
cargo build
To run the example, execute:
cargo run --example main
Tests
To run the tests (if available), execute:
cargo test
License
Distributed under the MIT License.
Contribution
Contributions are welcome! Please open an issue or submit a pull request.
Dependencies
~1.3–2MB
~36K SLoC