rlg-tower 0.0.18

Tower middleware for rlg. Emits per-request structured access logs for any `tower::Service<http::Request<_>>` — axum, tonic, hyper, lambda_runtime — with method, path, status, latency, and trace-ID propagation.
Documentation

Install

[dependencies]
rlg        = "0.0.18"
rlg-tower  = "0.0.18"

Requires Rust 1.89.0 or newer (edition 2024).

Quick start (axum)

use axum::{Router, routing::get};
use rlg::log_format::LogFormat;
use rlg::log_level::LogLevel;
use rlg_tower::RlgLayer;

let app: Router = Router::new()
    .route("/", get(|| async { "hello" }))
    .layer(
        RlgLayer::new()
            .level(LogLevel::INFO)
            .format(LogFormat::JSON)
            .component("api")
            .header("traceparent"),    // extract W3C trace-context
    );

What gets logged

One record per response, with these attributes:

Attribute Source
component "rlg-tower" (override with .component(...))
description "<METHOD> <path> -> <status>"
http.method request method
http.path request URI path
http.status response status code
http.latency_ms wall-clock milliseconds, poll-ready → ready response
trace_id extracted from a configured request header (W3C traceparent, B3 x-b3-traceid) if set

License

Dual-licensed under Apache 2.0 or MIT, at your option.