const (
// VantageEndpoint traces contain events not specific to a single connection.
VantageEndpoint = Vantage("endpoint")
// VantageClient traces follow a connection from the client's perspective.
VantageClient = Vantage("client")
// VantageServer traces follow a connection from the server's perspective.
VantageServer = Vantage("server")
)
func NewJSONHandler(opts HandlerOptions) slog.Handler
NewJSONHandler returns a handler which serializes qlog events to JSON.
The handler will write an endpoint-wide trace, and a separate trace for each connection. The HandlerOptions control the location traces are written.
It uses the streamable JSON Text Sequences mapping (JSON-SEQ) defined in draft-ietf-quic-qlog-main-schema-04, Section 6.2.
A JSONHandler may be used as the handler for a quic.Config.QLogLogger. It is not a general-purpose slog handler, and may not properly handle events from other sources.
HandlerOptions are options for a JSONHandler.
type HandlerOptions struct {
// Level reports the minimum record level that will be logged.
// If Level is nil, the handler assumes QLogLevelEndpoint.
Level slog.Leveler
// Dir is the directory in which to create trace files.
// The handler will create one file per connection.
// If NewTrace is non-nil or Dir is "", the handler will not create files.
Dir string
// NewTrace is called to create a new trace.
// If NewTrace is nil and Dir is set,
// the handler will create a new file in Dir for each trace.
NewTrace func(TraceInfo) (io.WriteCloser, error)
}
TraceInfo contains information about a trace.
type TraceInfo struct {
// Vantage is the vantage point of the trace.
Vantage Vantage
// GroupID identifies the logical group the trace belongs to.
// For a connection trace, the group will be the same for
// both the client and server vantage points.
GroupID string
}
Vantage is the vantage point of a trace.
type Vantage string