black

Crates.ioblack
lib.rsblack
version0.0.2
created_at2025-03-18 05:06:25.720039+00
updated_at2025-03-19 00:21:27.936619+00
descriptionA simple Black implementation in Rust for asynchronous, thread-safe logging.
homepagehttps://github.com/brenogonzaga/black
repositoryhttps://github.com/brenogonzaga/black
max_upload_size
id1596140
size16,026
Breno Gonzaga (brenogonzaga)

documentation

https://docs.rs/black

README

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

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.

Commit count: 4

cargo fmt