6 stable releases

new 3.0.2 May 5, 2025
3.0.1 Feb 3, 2025
3.0.0 Nov 1, 2024
2.0.0 Feb 13, 2024
1.1.0 Sep 30, 2023

#877 in Debugging

Download history 16/week @ 2025-01-15 45/week @ 2025-01-22 154/week @ 2025-01-29 89/week @ 2025-02-05 33/week @ 2025-02-12 27/week @ 2025-02-19 18/week @ 2025-02-26 9/week @ 2025-03-05 25/week @ 2025-03-12 3/week @ 2025-03-19 7/week @ 2025-03-26 15/week @ 2025-04-09 99/week @ 2025-04-30

114 downloads per month

MIT/Apache

32KB
257 lines

A logcontrol::LogControl1 frontend with zbus.

LogControl1 provides the D-Bus interface implementation. It receives the underlying logcontrol::LogControl1 as sole argument and exposes it over D-Bus, as a standard zbus D-Bus interface:

use logcontrol_zbus::{LogControl1, ConnectionBuilderExt};

#[async_std::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let control = create_log_control();
    let _conn = zbus::ConnectionBuilder::session()?
        .name("de.swsnr.logcontrol.SimpleServerExample")?
        .serve_log_control(LogControl1::new(control))?
        .build()
        .await?;

    // Do other things or go to wait forever
    std::future::pending::<()>().await;

    Ok(())
}

Note that for systemctl to find the log control interface with systemctl service-log-level and systemctl service-log-target you need to make sure that

  • the interface is registered under logcontrol::DBUS_OBJ_PATH, and
  • the unit file provides the claimed bus name in the BusName attribute.

Otherwise systemd will not be able to change the log level or target.


logcontrol-zbus

Crates.io docs.rs

zbus DBus frontend for the logcontrol interface.

Usage

$ cargo add logcontrol-zbus
use logcontrol_zbus::ConnectionBuilderExt;

#[async_std::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Use an implementation such as logcontrol-tracing
    let control = create_log_control();
    let _conn = zbus::ConnectionBuilder::session()?
        .name("de.swsnr.logcontrol.SimpleServerExample")?
        .serve_log_control(logcontrol_zbus::LogControl1::new(control))?
        .build()
        .await?;

    // Do other things or go to wait forever
    std::future::pending::<()>().await;

    Ok(())
}

Dependencies

~9–18MB
~288K SLoC