forked from quic-go/quic-go
qlog the quic-go version
This only works when quic-go is used as a library.
This commit is contained in:
19
qlog/qlog.go
19
qlog/qlog.go
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"runtime/debug"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -17,6 +18,24 @@ import (
|
||||
"github.com/francoispqt/gojay"
|
||||
)
|
||||
|
||||
var quicGoVersion = "(devel)"
|
||||
|
||||
func init() {
|
||||
info, ok := debug.ReadBuildInfo()
|
||||
if !ok { // no build info available. This happens when quic-go is not used as a library.
|
||||
return
|
||||
}
|
||||
for _, d := range info.Deps {
|
||||
if d.Path == "github.com/lucas-clemente/quic-go" {
|
||||
quicGoVersion = d.Version
|
||||
if d.Replace != nil {
|
||||
quicGoVersion += " (replaced)"
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const eventChanSize = 50
|
||||
|
||||
type tracer struct {
|
||||
|
||||
@@ -17,6 +17,7 @@ func (l topLevel) MarshalJSONObject(enc *gojay.Encoder) {
|
||||
enc.StringKey("qlog_format", "NDJSON")
|
||||
enc.StringKey("qlog_version", "draft-02")
|
||||
enc.StringKeyOmitEmpty("title", "quic-go qlog")
|
||||
enc.StringKey("code_version", quicGoVersion)
|
||||
enc.ObjectKey("trace", l.trace)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user