summaryrefslogtreecommitdiff
path: root/bilibili/request.go
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-09-10 18:28:19 +0800
committerKeuin <[email protected]>2022-09-10 18:28:19 +0800
commit73b2b41e777614d7c372b9d92a90b5fbb68d05c0 (patch)
tree39bf028dbe68347444dc25abdfd29d1cad7d2989 /bilibili/request.go
parent5664705557ad5e4a3bd1234b12e4054a1a9579c1 (diff)
Replace all logger usages to custom logging.Logger.
Diffstat (limited to 'bilibili/request.go')
-rw-r--r--bilibili/request.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/bilibili/request.go b/bilibili/request.go
index f9e2088..7de35d3 100644
--- a/bilibili/request.go
+++ b/bilibili/request.go
@@ -18,7 +18,7 @@ func (b Bilibili) newRequest(
) (req *http.Request, err error) {
req, err = http.NewRequestWithContext(b.ctx, method, url, body)
if err != nil {
- b.error.Printf("Cannot create HTTP request instance: %v. Method: %v, URL: %v", err, method, url)
+ b.logger.Error("Cannot create HTTP request instance: %v. Method: %v, URL: %v", err, method, url)
return
}
req.Header.Set("User-Agent", b.userAgent)
@@ -48,24 +48,24 @@ func callGet[T BaseResponse[V], V any](b Bilibili, url string) (resp T, err erro
err = validateHttpStatus(r)
if err != nil {
- b.error.Printf("%v", err)
+ b.logger.Error("%v", err)
return
}
data, err := io.ReadAll(r.Body)
if err != nil {
- b.error.Printf("Error when reading HTTP response on API %v: %v", url, err)
+ b.logger.Error("Error when reading HTTP response on API %v: %v", url, err)
return
}
err = json.Unmarshal(data, &resp)
if err != nil {
- b.error.Printf("Invalid JSON body of HTTP response on API %v: %v. Text: \"%v\"",
+ b.logger.Error("Invalid JSON body of HTTP response on API %v: %v. Text: \"%v\"",
url, err, string(data))
return
}
- b.debug.Printf("HTTP %v, len: %v bytes, url: %v", r.StatusCode, len(data), url)
+ b.logger.Debug("HTTP %v, len: %v bytes, url: %v", r.StatusCode, len(data), url)
return
}
@@ -84,7 +84,7 @@ func (b Bilibili) Do(req *http.Request) (resp *http.Response, err error) {
isAddrErr := common.IsErrorOfType(err, &net.AddrError{})
if err == nil || !isOpErr || !isAddrErr {
// return the first success request
- b.loggerCommon.info.Printf("Request success with network %v.", typeName)
+ b.logger.Info("Request success with network %v.", typeName)
return
}
}