Crates.io | unsafe_forestry |
lib.rs | unsafe_forestry |
version | 1.7.1 |
created_at | 2024-12-31 23:34:24.881418+00 |
updated_at | 2025-01-06 09:30:17.141403+00 |
description | A simple cross-platform CLI logging library for Rust, now static and mutable |
homepage | https://github.com/uptudev/forestry |
repository | https://github.com/uptudev/forestry |
max_upload_size | |
id | 1500454 |
size | 31,453 |
A simple, efficient, concise, and elegant logging library for Rust, remade with static mut
instead of a wrapper object.
To install forestry, simply add it to your Rust project via Cargo:
cargo add unsafe_forestry
Forestry depends on the colored
crate for colorized output.
Forestry is a simple logging library that allows you to log messages to the console with different levels of severity. Here's an example of how to use it:
src/main.rs
use unsafe_forestry::prelude::*;
info("This is an info message.");
warn("This is a warning message.");
error("This is an error message.");
success("This is a success message.");
critical("This is a critical message.");
This will output the following to the console:
[0000:*] This is an info message.
[0001:~] This is a warning message.
[0002:!] This is an error message.
[0003:+] This is a success message.
[0004:%] This is a critical message.
It will also be coloured in most terminals.
All formatting is optional; please see the documentation at Docs.rs, specifically for crate::logs::Options
. Optional file output and timer inclusion is also supported via the same crate::logs::Options
enum.
Forestry also supports asynchronous logging. To enable this feature, simply add the async
feature to forestry
's declaration in your Cargo.toml
file.
First, add the async
feature to unsafe_forestry
in your Cargo.toml
file by changing the default declaration to either of the following:
Cargo.toml
[dependencies]
unsafe_forestry = { version = ">=1.5", features = ["async"] }
or
Cargo.toml
[dependencies.unsafe_forestry]
version = ">=1.5"
features = ["async"]
Then, the internal print calls will be asynchronous futures. This is useful for logging in async functions or in async contexts.
If you would like to contribute to forestry, please open an issue or submit a pull request.
This code is dual-licensed under either the MIT or Apache 2.0 license, at your option. Please see the LICENSE
file for more information.