The qlog crate is an implementation of the qlog main schema and qlog QUIC and HTTP/3 events that attempts to closely follow the format of the qlog TypeScript schema. This is just a data model and no support is provided for logging IO, applications can decide themselves the most appropriate method.
The crate uses Serde for conversion between Rust and JSON.
Getting Started
Creating a trace
A typical application needs a single qlog trace that it appends QUIC and/or HTTP/3 events to:
let trace = Trace ;
Adding events
Qlog Events are added to qlog::Trace.events. Utility method are provided for
the various types of QUIC and HTTP/3 events. The following example demonstrates
how to log a QUIC packet containing a single Crypto frame, it uses the
push_transport_event() and QuicFrame::crypto() methods to capture a
PacketSent event and its EventData.
trace.push_transport_event;
Serializing
Simply:
to_string_pretty.unwrap;
``
which would generate the following:
{ "vantage_point": { "name": "Example client", "type": "client" }, "title": "Example qlog trace", "description": "Example qlog trace description", "configuration": { "time_units": "ms", "time_offset": "0" }, "event_fields": [ "relative_time", "category", "event", "data" ], "events": [ [ "0", "transport", "packet_sent", { "packet_type": "initial", "header": { "packet_number": "0", "packet_size": 1251, "payload_length": 1224, "version": "0xff000018", "scil": "8", "dcil": "8", "scid": "7e37e4dcc6682da8", "dcid": "36ce104eee50101c" }, "frames": [ { "frame_type": "crypto", "offset": "0", "length": "100", } ] } ] ] }