Package qlog serializes qlog events.
import "golang.org/x/net/quic/qlog"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")
)// Vantage is the vantage point from which a trace is recorded
type Vantage string
func (v Vantage) String() string// TraceInfo contains information about a trace
type TraceInfo struct {
Vantage Vantage // Vantage point of the trace
GroupID string // Identifies the logical group the trace belongs to
}This package is used internally by the quic package for logging QUIC protocol events in qlog format. Use the QLogLogger field in quic.Config to enable qlog logging.
import (
"golang.org/x/net/quic"
"log/slog"
"os"
)
func setupQLogLogging() *quic.Config {
// Create qlog logger
qlogFile, err := os.Create("quic.qlog")
if err != nil {
panic(err)
}
logger := slog.New(slog.NewJSONHandler(qlogFile, &slog.HandlerOptions{
Level: quic.QLogLevelPacket,
}))
return &quic.Config{
QLogLogger: logger,
}
}