mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
create a logger interface and use it everywhere
This commit is contained in:
parent
1e9b3f0bb2
commit
948eef3e42
52 changed files with 411 additions and 281 deletions
|
@ -19,12 +19,14 @@ func main() {
|
|||
flag.Parse()
|
||||
urls := flag.Args()
|
||||
|
||||
logger := utils.DefaultLogger
|
||||
|
||||
if *verbose {
|
||||
utils.SetLogLevel(utils.LogLevelDebug)
|
||||
logger.SetLogLevel(utils.LogLevelDebug)
|
||||
} else {
|
||||
utils.SetLogLevel(utils.LogLevelInfo)
|
||||
logger.SetLogLevel(utils.LogLevelInfo)
|
||||
}
|
||||
utils.SetLogTimeFormat("")
|
||||
logger.SetLogTimeFormat("")
|
||||
|
||||
versions := protocol.SupportedVersions
|
||||
if *tls {
|
||||
|
@ -42,21 +44,21 @@ func main() {
|
|||
var wg sync.WaitGroup
|
||||
wg.Add(len(urls))
|
||||
for _, addr := range urls {
|
||||
utils.Infof("GET %s", addr)
|
||||
logger.Infof("GET %s", addr)
|
||||
go func(addr string) {
|
||||
rsp, err := hclient.Get(addr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
utils.Infof("Got response for %s: %#v", addr, rsp)
|
||||
logger.Infof("Got response for %s: %#v", addr, rsp)
|
||||
|
||||
body := &bytes.Buffer{}
|
||||
_, err = io.Copy(body, rsp.Body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
utils.Infof("Request Body:")
|
||||
utils.Infof("%s", body.Bytes())
|
||||
logger.Infof("Request Body:")
|
||||
logger.Infof("%s", body.Bytes())
|
||||
wg.Done()
|
||||
}(addr)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue