#logging #tracing #daemon #idiomatic #structured-logging #trace-logging #log-structured #thread-safe #libdlt

dlt-rs

Safe and idiomatic Rust wrapper for the C library libdlt to provide DLT logging capabilities for Rust applications

1 unstable release

Uses new Rust 2024

0.1.0 Dec 1, 2025

#352 in Debugging

28 downloads per month
Used in tracing-dlt

Apache-2.0

66KB
1K SLoC

Rust 1K SLoC // 0.1% comments C 120 SLoC // 0.1% comments

dlt-rs

Crates.io Documentation License Safe and idiomatic Rust wrapper for the COVESA DLT (Diagnostic Log and Trace) library.

Overview

dlt-rs provides a safe, ergonomic Rust API for logging to the COVESA DLT daemon. It wraps the low-level dlt-sys FFI bindings with a type-safe interface.

Features

  • Type-safe API - No unsafe code in your application
  • Structured logging - Log typed fields (integers, floats, strings, etc.)
  • RAII-based resource management - Automatic cleanup
  • Thread-safe - Safe for concurrent use
  • Zero-copy where possible for performance
  • Dynamic log levels - Responds to DLT daemon configuration changes

Basic Example

use dlt_rs::{DltApplication, DltId, DltLogLevel};
fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Register application (one per process)
    let app = DltApplication::register(
        &DltId::new(b"MBTI")?,
        "Measurement & Bus Trace Interface"
    )?;
    // Create a logging context
    let ctx = app.create_context(
        &DltId::new(b"CTX1")?,
        "Main Context"
    )?;
    // Simple text logging
    ctx.log(DltLogLevel::Info, "Hello DLT!")?;
    Ok(())
}

Structured Logging

use dlt_rs::{DltLogLevel};
// Log structured data with typed fields
let mut writer = ctx.log_write_start(DltLogLevel::Info)?;
writer
    .write_string("Temperature:")?
    .write_float32(87.5)?
    .write_string("°C")?;
writer.finish()?;

Tracing Integration

For integration with the tracing ecosystem, see the tracing-dlt crate.

Features

  • trace_load_ctrl - Enable DLT load control support (optional)

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.

Contributing

This project is part of Eclipse OpenSOVD, but can be used independently. See CONTRIBUTING.md for guidelines.

References

Dependencies

~4MB
~63K SLoC