kamu-logging

Crates.iokamu-logging
lib.rskamu-logging
version0.1.2
created_at2025-08-08 00:53:17.922725+00
updated_at2025-08-08 00:53:17.922725+00
descriptionSmall helper crate to configure structured logging for IMMER's services using the tracing ecosystem.
homepage
repositoryhttps://github.com/pt-immer/kamu-logging
max_upload_size
id1786046
size59,198
Aditya Kresna (Ujang360)

documentation

https://docs.rs/kamu-logging

README

kamu‑logging

kamu‑logging is a small helper crate to configure structured logging for services built by PT IMMER. It wraps the tracing ecosystem and selects an appropriate backend depending on your target platform.

Supported targets

  • Systemd (default) – When the systemd feature is enabled, the crate initialises a tracing subscriber that forwards logs from the log crate, parses the RUST_LOG environment variable, and emits either coloured console output or forwards events to journald when not attached to a TTY.

  • WASM (wasm32 feature) – On WebAssembly targets the crate installs console_error_panic_hook to improve panic messages and configures the wasm‑tracing subscriber.

  • Actix Web (logging‑actix‑web feature) – Exposes a get_actix_web_logger() function returning an Actix Web middleware logger.

Usage

Add the crate to your Cargo.toml and call kamu_logging::init() early in main. At least one of the mutually exclusive systemd or wasm32 features must be enabled. The systemd feature is enabled by default.

[dependencies]
kamu‑logging = "0.1.2"
fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialise logging.  This will forward any logs emitted via the
    // `log` crate into the `tracing` subscriber and pick the
    // appropriate backend.
    kamu_logging::init()?;

    // Your application logic here.
    Ok(())
}

When building for wasm32 targets, enable the wasm32 feature and disable the default features:

[dependencies]
kamu‑logging = { version = "0.1.2", default‑features = false, features = ["wasm32"] }

License

This project is licensed under the MIT License. See the LICENSE file for details.

Commit count: 0

cargo fmt