client only.Expand description
Request/response logging for trillium-client.
This module is gated behind the client cargo feature. It provides ClientLogger, a
ClientHandler that emits a log line per request, with a composable formatter system that
mirrors the server-side Logger in spirit.
§Lifecycle
ClientLogger records a request-start instant the first time it runs and emits the
formatted line after the response is available. Its position in the handler chain
determines the scope of response_time — only handlers running
after ClientLogger are timed.
A log line is emitted for every request, regardless of outcome: successful responses,
responses synthesized by an upstream handler (cache hit, mock), and transport-layer
failures (connection refused, TLS error, timeout) all land in the log. The dev_formatter
renders the transport error inline when one is stashed on the conn; custom formatters can
pick it up via the error component.
§Formatters
See ClientLogFormatter for the trait, and the formatters submodule for the building
blocks. The default is dev_formatter.
§Example
use trillium_client::Client;
use trillium_logger::client::{ClientLogger, formatters};
let client = Client::new(client_config()).with_handler(ClientLogger::new().with_formatter((
formatters::method,
" ",
formatters::url,
" -> ",
formatters::status,
)));Re-exports§
pub use formatters::dev_formatter;
Modules§
- formatters
- Building-block formatters for
ClientLogger.
Structs§
- Client
Logger - The
ClientHandlerthat emits one log line per request.
Traits§
- Client
LogFormatter - The interface to format a
client::Connas aDisplay-able output.
Functions§
- client_
logger - Convenience alias for
ClientLogger::new.