mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-05 05:07:36 +03:00
example: remove -v flag and custom logger configuration (#4242)
Users can adjust the log level using the QUIC_GO_LOG_LEVEL environment variable. This is more representative of how quic-go would actually be used, since the logger is part of an internal package.
This commit is contained in:
parent
2cd9ed38f1
commit
13327521a5
2 changed files with 5 additions and 26 deletions
|
@ -23,7 +23,6 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
verbose := flag.Bool("v", false, "verbose")
|
||||
quiet := flag.Bool("q", false, "don't print the data")
|
||||
keyLogFile := flag.String("keylog", "", "key log file")
|
||||
insecure := flag.Bool("insecure", false, "skip certificate verification")
|
||||
|
@ -31,15 +30,6 @@ func main() {
|
|||
flag.Parse()
|
||||
urls := flag.Args()
|
||||
|
||||
logger := utils.DefaultLogger
|
||||
|
||||
if *verbose {
|
||||
logger.SetLogLevel(utils.LogLevelDebug)
|
||||
} else {
|
||||
logger.SetLogLevel(utils.LogLevelInfo)
|
||||
}
|
||||
logger.SetLogTimeFormat("")
|
||||
|
||||
var keyLog io.Writer
|
||||
if len(*keyLogFile) > 0 {
|
||||
f, err := os.Create(*keyLogFile)
|
||||
|
@ -84,13 +74,13 @@ func main() {
|
|||
var wg sync.WaitGroup
|
||||
wg.Add(len(urls))
|
||||
for _, addr := range urls {
|
||||
logger.Infof("GET %s", addr)
|
||||
log.Printf("GET %s", addr)
|
||||
go func(addr string) {
|
||||
rsp, err := hclient.Get(addr)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
logger.Infof("Got response for %s: %#v", addr, rsp)
|
||||
log.Printf("Got response for %s: %#v", addr, rsp)
|
||||
|
||||
body := &bytes.Buffer{}
|
||||
_, err = io.Copy(body, rsp.Body)
|
||||
|
@ -98,10 +88,9 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
if *quiet {
|
||||
logger.Infof("Response Body: %d bytes", body.Len())
|
||||
log.Printf("Response Body: %d bytes", body.Len())
|
||||
} else {
|
||||
logger.Infof("Response Body:")
|
||||
logger.Infof("%s", body.Bytes())
|
||||
log.Printf("Response Body (%d bytes):\n%s", body.Len(), body.Bytes())
|
||||
}
|
||||
wg.Done()
|
||||
}(addr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue