Merge pull request #2495 from lucas-clemente/interop-logging

improve logging in interop client and server
This commit is contained in:
Marten Seemann
2020-04-16 09:28:09 +07:00
committed by GitHub
3 changed files with 8 additions and 1 deletions

View File

@@ -5,6 +5,7 @@ import (
"crypto/tls"
"errors"
"io/ioutil"
"log"
"net"
"net/http"
"strings"
@@ -38,6 +39,8 @@ func (r *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
return nil, errors.New("only GET requests supported")
}
log.Printf("Requesting %s.\n", req.URL)
r.mutex.Lock()
hostname := authorityAddr("https", hostnameFromRequest(req))
if r.clients == nil {

View File

@@ -95,7 +95,7 @@ func (s *Server) handleConn(sess quic.Session) {
}
go func() {
if err := s.handleStream(str); err != nil {
log.Printf("Handling stream failed: %s", err.Error())
log.Printf("Handling stream failed: %s\n", err.Error())
}
}()
}
@@ -109,6 +109,9 @@ func (s *Server) handleStream(str quic.Stream) error {
request := string(reqBytes)
request = strings.TrimRight(request, "\r\n")
request = strings.TrimRight(request, " ")
log.Printf("Received request: %s\n", request)
if request[:5] != "GET /" {
str.CancelWrite(42)
return nil

View File

@@ -42,6 +42,7 @@ func GetQLOGWriter() (func(connID []byte) io.WriteCloser, error) {
log.Printf("Failed to create qlog file %s: %s", path, err.Error())
return nil
}
log.Printf("Created qlog file: %s\n", path)
return utils.NewBufferedWriteCloser(bufio.NewWriter(f), f)
}, nil
}