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:
albertony
2024-08-18 16:58:35 +02:00
committed by Nick Craig-Wood
parent 88b0757288
commit bcdfad3c83
64 changed files with 333 additions and 357 deletions

View File

@@ -2,10 +2,10 @@ package systemd
import (
"fmt"
"log"
"sync"
"github.com/coreos/go-systemd/v22/daemon"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/lib/atexit"
)
@@ -18,13 +18,13 @@ import (
// It should not be called as a result of rc commands. See #7540.
func Notify() func() {
if _, err := daemon.SdNotify(false, daemon.SdNotifyReady); err != nil {
log.Printf("failed to notify ready to systemd: %v", err)
fs.Logf(nil, "failed to notify ready to systemd: %v", err)
}
var finaliseOnce sync.Once
finalise := func() {
finaliseOnce.Do(func() {
if _, err := daemon.SdNotify(false, daemon.SdNotifyStopping); err != nil {
log.Printf("failed to notify stopping to systemd: %v", err)
fs.Logf(nil, "failed to notify stopping to systemd: %v", err)
}
})
}