Crate tracing_dlt

Source
Expand description

Tracing integration for COVESA DLT (Diagnostic Log and Trace)

tracing subscriber layer that forwards tracing events to the DLT daemon, enabling standard tracing macros (info!, debug!, error!, etc.) to send logs to DLT for centralized diagnostics.

§Quick Start

use tracing_dlt::{DltLayer, DltId};
use tracing::{info, span, Level};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

// Register DLT layer
let app_id = DltId::new(b"MBTI")?;
tracing_subscriber::registry()
    .with(DltLayer::new(&app_id, "My Beautiful Trace Ingestor")?)
    .init();

// Basic logging (uses default "DFLT" context)
info!("Application started");
// DLT Output: MBTI DFLT log info V 1 [lib: Application started]
//             ^^^^ ^^^^ ^^^ ^^^^ ^ ^  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//             |    |    |   |    | |  Message (crate + msg)
//             |    |    |   |    | Number of arguments
//             |    |    |   |    Verbose flag
//             |    |    |   Log level
//             |    |    Log type
//             |    Context ID (default)
//             Application ID

// Custom DLT context per span
let span = span!(Level::INFO, "network", dlt_context = "NET");
let _guard = span.enter();
info!(bytes = 1024, "Data received");
// DLT Output: MBTI NET log info V 2 [network: lib: Data received bytes = 1024]
//                  ^^^               ^^^^^^^^       ^^^^^^^^^^^^        ^^^^
//             |    Custom context    Span name      Message             Structured field

§Core Features

  • Per-span contexts - Use dlt_context field to route logs to specific DLT contexts
  • Structured logging - Span fields automatically included in messages with native types
  • Layer composition - Combine with other tracing layers (fmt, file, etc.)
  • Thread-safe - Full Send + Sync support

§DLT Context Management

Events outside spans use the default “DFLT” context. Spans can specify their own context with the dlt_context field (auto-creates and caches contexts):

// Nested contexts
let outer = span!(Level::INFO, "can_bus", dlt_context = "CAN");
let _g1 = outer.enter();
info!(msg_id = 0x123, "CAN frame received");

let inner = span!(Level::DEBUG, "decode", dlt_context = "CTRL");
let _g2 = inner.enter();
info!("Decoded steering command");

§See Also

  • [dlt_sys] - Low-level Rust bindings for DLT
  • tracing - Application-level tracing framework
  • COVESA DLT - The DLT daemon

Structs§

DltApplication
Singleton guard for DLT application registration
DltId
A DLT identifier (Application ID or Context ID)
DltLayer
COVESA DLT layer for tracing

Enums§

DltError
Internal error types for Rust-side operations (not from libdlt)
DltLogLevel
DLT log level
DltSysError
DLT return value error types (from libdlt C library)