logcontrol-log

Crates.iologcontrol-log
lib.rslogcontrol-log
version0.1.0
sourcesrc
created_at2023-10-26 13:52:48.607476
updated_at2023-10-26 13:52:48.607476
descriptionlog backend for the log control interface
homepagehttps://github.com/swsnr/logcontrol.rs
repositoryhttps://github.com/swsnr/logcontrol.rs.git
max_upload_size
id1014490
size52,186
Sebastian Wiesner (swsnr)

documentation

https://docs.rs/logcontrol-log

README

logcontrol-log

Crates.io docs.rs

log implementation for the logcontrol interface.

Usage

$ cargo add logcontrol-log
use std::error::Error;

use logcontrol_log::{LogController, LogFactory};
use logcontrol_zbus::ConnectionBuilderExt;
use zbus::ConnectionBuilder;

struct Factory;

impl LogFactory for Factory {
    fn create_console_log(&self) -> Result<Box<dyn log::Log>, logcontrol::LogControl1Error> {
        Ok(Box::new(env_logger::Builder::from_default_env().build()))
    }
}

#[async_std::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let control = LogController::install_auto(Factory, log::Level::Info)?;
    let _conn = ConnectionBuilder::session()?
        .name("de.swsnr.logcontrol.TracingServerExample")?
        .serve_log_control(logcontrol_zbus::LogControl1::new(control))?
        .build()
        .await?;

    loop {
        // Service event loop
    }
}
Commit count: 84

cargo fmt