mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01: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
@@ -5,7 +5,6 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
|
||||
"github.com/rclone/rclone/fs"
|
||||
@@ -27,7 +26,7 @@ func cleanFs(ctx context.Context, remote string, cleanup bool) error {
|
||||
}
|
||||
var lastErr error
|
||||
if cleanup {
|
||||
log.Printf("%q - running cleanup", remote)
|
||||
fs.Logf(nil, "%q - running cleanup", remote)
|
||||
err = operations.CleanUp(ctx, f)
|
||||
if err != nil {
|
||||
lastErr = err
|
||||
@@ -43,10 +42,10 @@ func cleanFs(ctx context.Context, remote string, cleanup bool) error {
|
||||
fullPath := fspath.JoinRootPath(remote, dirPath)
|
||||
if MatchTestRemote.MatchString(dirPath) {
|
||||
if *dryRun {
|
||||
log.Printf("Not Purging %s - -dry-run", fullPath)
|
||||
fs.Logf(nil, "Not Purging %s - -dry-run", fullPath)
|
||||
return nil
|
||||
}
|
||||
log.Printf("Purging %s", fullPath)
|
||||
fs.Logf(nil, "Purging %s", fullPath)
|
||||
dir, err := fs.NewFs(context.Background(), fullPath)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("NewFs failed: %w", err)
|
||||
@@ -75,11 +74,11 @@ func cleanRemotes(conf *Config) error {
|
||||
var lastError error
|
||||
for _, backend := range conf.Backends {
|
||||
remote := backend.Remote
|
||||
log.Printf("%q - Cleaning", remote)
|
||||
fs.Logf(nil, "%q - Cleaning", remote)
|
||||
err := cleanFs(context.Background(), remote, backend.CleanUp)
|
||||
if err != nil {
|
||||
lastError = err
|
||||
log.Printf("Failed to purge %q: %v", remote, err)
|
||||
fs.Logf(nil, "Failed to purge %q: %v", remote, err)
|
||||
}
|
||||
}
|
||||
return lastError
|
||||
|
||||
Reference in New Issue
Block a user