1
0
mirror of https://github.com/rancher/os.git synced 2025-08-24 17:38:17 +00:00

Adjust log output

This commit is contained in:
niusmallnan 2019-08-17 12:05:10 +08:00
parent a8cf965b2a
commit 3fac5f7604

View File

@ -18,11 +18,12 @@ import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log"
"net/http" "net/http"
neturl "net/url" neturl "net/url"
"strings" "strings"
"time" "time"
"github.com/rancher/os/pkg/log"
) )
const ( const (
@ -120,14 +121,14 @@ func (h *HTTPClient) GetRetry(rawurl string) ([]byte, error) {
duration := h.InitialBackoff duration := h.InitialBackoff
for retry := 1; retry <= h.MaxRetries; retry++ { for retry := 1; retry <= h.MaxRetries; retry++ {
log.Printf("Fetching data from %s. Attempt #%d", dataURL, retry) log.Debugf("Fetching data from %s. Attempt #%d", dataURL, retry)
data, err := h.Get(dataURL) data, err := h.Get(dataURL)
switch err.(type) { switch err.(type) {
case ErrNetwork: case ErrNetwork:
log.Printf(err.Error()) log.Debugf(err.Error())
case ErrServer: case ErrServer:
log.Printf(err.Error()) log.Debugf(err.Error())
case ErrNotFound: case ErrNotFound:
return data, err return data, err
default: default:
@ -135,7 +136,7 @@ func (h *HTTPClient) GetRetry(rawurl string) ([]byte, error) {
} }
duration = ExpBackoff(duration, h.MaxBackoff) duration = ExpBackoff(duration, h.MaxBackoff)
log.Printf("Sleeping for %v...", duration) log.Debugf("Sleeping for %v...", duration)
time.Sleep(duration) time.Sleep(duration)
} }