lunatic-log

Crates.iolunatic-log
lib.rslunatic-log
version0.4.0
sourcesrc
created_at2022-08-08 13:50:16.150542
updated_at2023-05-05 09:14:00.362459
descriptionA logging library for lunatic Rust applications
homepage
repositoryhttps://github.com/lunatic-solutions/lunatic-log-rs
max_upload_size
id640848
size67,005
Bernard Kolobara (bkolobara)

documentation

README

A logging library for lunatic Rust applications.

Why a new logging library?

Current logging solutions in Rust (log, tracing, ...) depend on global static variables that are initialized at the start of the app. This doesn't work in lunatic, where each process gets their own memory space. You would need to re-initialize the logger for each process, and that is not practical.

lunatic-log allows you to run a log subscriber process that collects logging messages from all running processes.

How to use lunatic-log?

Add it as a dependency:

lunatic-log = "0.2"

In your code:

use lunatic_log::{info, subscriber::fmt::FmtSubscriber, LevelFilter};

fn main() {
    // Initialize subscriber
    lunatic_log::init(FmtSubscriber::new(LevelFilter::Info).pretty());

    // Log message
    info!("Hello, {}", "World");

    // Wait for events to propagate and display before exiting app
    lunatic::sleep(std::time::Duration::from_millis(50));
}

License

Licensed under either of

at your option.

Commit count: 28

cargo fmt