mirror of
https://github.com/rclone/rclone.git
synced 2025-12-15 15:53:41 +00:00
build: update logging statements to make json log work - fixes #6038
This changes log statements from log to fs package, which is required for --use-json-log to properly make log output in JSON format. The recently added custom linting rule, handled by ruleguard via gocritic via golangci-lint, warns about these and suggests the alternative. Fixing was therefore basically running "golangci-lint run --fix", although some manual fixup of mainly imports are necessary following that.
This commit is contained in:
committed by
Nick Craig-Wood
parent
88b0757288
commit
bcdfad3c83
@@ -9,7 +9,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -78,7 +77,7 @@ certificate authority certificate.
|
||||
`
|
||||
tmpl, err := template.New("server help").Parse(help)
|
||||
if err != nil {
|
||||
log.Fatal("Fatal error parsing template", err)
|
||||
fs.Fatal(nil, fmt.Sprint("Fatal error parsing template", err))
|
||||
}
|
||||
|
||||
data := struct {
|
||||
@@ -89,7 +88,7 @@ certificate authority certificate.
|
||||
buf := &bytes.Buffer{}
|
||||
err = tmpl.Execute(buf, data)
|
||||
if err != nil {
|
||||
log.Fatal("Fatal error executing template", err)
|
||||
fs.Fatal(nil, fmt.Sprint("Fatal error executing template", err))
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
@@ -199,7 +198,7 @@ func (s instance) serve(wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
err := s.httpServer.Serve(s.listener)
|
||||
if err != http.ErrServerClosed && err != nil {
|
||||
log.Printf("%s: unexpected error: %s", s.listener.Addr(), err.Error())
|
||||
fs.Logf(nil, "%s: unexpected error: %s", s.listener.Addr(), err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +496,7 @@ func (s *Server) Shutdown() error {
|
||||
expiry := time.Now().Add(gracefulShutdownTime)
|
||||
ctx, cancel := context.WithDeadline(context.Background(), expiry)
|
||||
if err := ii.httpServer.Shutdown(ctx); err != nil {
|
||||
log.Printf("error shutting down server: %s", err)
|
||||
fs.Logf(nil, "error shutting down server: %s", err)
|
||||
}
|
||||
cancel()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user