nquic_qlog_file (nquic v1.0.0)

View Source

File backend for nquic_qlog. Writes draft-ietf-quic-qlog NDJSON to a per-connection file.

First line is a JSON object describing the trace (qlog_format = "JSON-SEQ", schema version, connection ID, vantage point). Each subsequent line is a single JSON event.

Path conventions: callers either pass an absolute path (file is truncated and reopened) or a directory (a unique file is created named after the connection's hex-encoded DCID).

This module deliberately uses raw, delayed-write file ports for the steady-state event stream. Each event is one io_lib call and one file:write (delayed by 256 KiB or 100 ms). Closing the file flushes the buffer. The format is line-oriented so an interrupted trace still loads in qvis.

Summary

Functions

event/2

-spec event(#state{fd :: file:io_device(),
                   path :: file:filename_all(),
                   cid_hex :: binary(),
                   start_us :: integer()},
            {nquic_qlog:event_name(), nquic_qlog:event_data()}) ->
               {ok,
                #state{fd :: file:io_device(),
                       path :: file:filename_all(),
                       cid_hex :: binary(),
                       start_us :: integer()}}.

init/2

-spec init(nquic:connection_id(), map()) ->
              {ok,
               #state{fd :: file:io_device(),
                      path :: file:filename_all(),
                      cid_hex :: binary(),
                      start_us :: integer()}} |
              {error, term()}.

terminate/2

-spec terminate(#state{fd :: file:io_device(),
                       path :: file:filename_all(),
                       cid_hex :: binary(),
                       start_us :: integer()},
                term()) ->
                   ok.