simplify the Tracer interface by combining the TracerFor... methods

This commit is contained in:
Marten Seemann
2020-07-11 10:46:35 +07:00
parent ece3592544
commit ee24d3899e
32 changed files with 139 additions and 194 deletions

View File

@@ -8,6 +8,8 @@ import (
"os"
"strings"
"github.com/lucas-clemente/quic-go/logging"
"github.com/lucas-clemente/quic-go/internal/utils"
)
@@ -25,7 +27,7 @@ func GetSSLKeyLog() (io.WriteCloser, error) {
}
// GetQLOGWriter creates the QLOGDIR and returns the GetLogWriter callback
func GetQLOGWriter() (func(connID []byte) io.WriteCloser, error) {
func GetQLOGWriter() (func(perspective logging.Perspective, connID []byte) io.WriteCloser, error) {
qlogDir := os.Getenv("QLOGDIR")
if len(qlogDir) == 0 {
return nil, nil
@@ -35,7 +37,7 @@ func GetQLOGWriter() (func(connID []byte) io.WriteCloser, error) {
return nil, fmt.Errorf("failed to create qlog dir %s: %s", qlogDir, err.Error())
}
}
return func(connID []byte) io.WriteCloser {
return func(_ logging.Perspective, connID []byte) io.WriteCloser {
path := fmt.Sprintf("%s/%x.qlog", strings.TrimRight(qlogDir, "/"), connID)
f, err := os.Create(path)
if err != nil {