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-09-06 17:04:18 +01:00
committed by Nick Craig-Wood
parent 88b0757288
commit bcdfad3c83
64 changed files with 333 additions and 357 deletions
+4 -3
View File
@@ -1,10 +1,11 @@
package genautocomplete
import (
"log"
"fmt"
"os"
"github.com/rclone/rclone/cmd"
"github.com/rclone/rclone/fs"
"github.com/spf13/cobra"
)
@@ -50,7 +51,7 @@ current shell.
if args[0] == "-" {
err := cmd.Root.GenBashCompletionV2(os.Stdout, false)
if err != nil {
log.Fatal(err)
fs.Fatal(nil, fmt.Sprint(err))
}
return
}
@@ -58,7 +59,7 @@ current shell.
}
err := cmd.Root.GenBashCompletionFileV2(out, false)
if err != nil {
log.Fatal(err)
fs.Fatal(nil, fmt.Sprint(err))
}
},
}
+4 -3
View File
@@ -1,10 +1,11 @@
package genautocomplete
import (
"log"
"fmt"
"os"
"github.com/rclone/rclone/cmd"
"github.com/rclone/rclone/fs"
"github.com/spf13/cobra"
)
@@ -39,7 +40,7 @@ If output_file is "-", then the output will be written to stdout.
if args[0] == "-" {
err := cmd.Root.GenFishCompletion(os.Stdout, true)
if err != nil {
log.Fatal(err)
fs.Fatal(nil, fmt.Sprint(err))
}
return
}
@@ -47,7 +48,7 @@ If output_file is "-", then the output will be written to stdout.
}
err := cmd.Root.GenFishCompletionFile(out, true)
if err != nil {
log.Fatal(err)
fs.Fatal(nil, fmt.Sprint(err))
}
},
}
@@ -1,10 +1,11 @@
package genautocomplete
import (
"log"
"fmt"
"os"
"github.com/rclone/rclone/cmd"
"github.com/rclone/rclone/fs"
"github.com/spf13/cobra"
)
@@ -31,13 +32,13 @@ If output_file is "-" or missing, then the output will be written to stdout.
if len(args) == 0 || (len(args) > 0 && args[0] == "-") {
err := cmd.Root.GenPowerShellCompletion(os.Stdout)
if err != nil {
log.Fatal(err)
fs.Fatal(nil, fmt.Sprint(err))
}
return
}
err := cmd.Root.GenPowerShellCompletionFile(args[0])
if err != nil {
log.Fatal(err)
fs.Fatal(nil, fmt.Sprint(err))
}
},
}
+5 -4
View File
@@ -1,10 +1,11 @@
package genautocomplete
import (
"log"
"fmt"
"os"
"github.com/rclone/rclone/cmd"
"github.com/rclone/rclone/fs"
"github.com/spf13/cobra"
)
@@ -39,7 +40,7 @@ If output_file is "-", then the output will be written to stdout.
if args[0] == "-" {
err := cmd.Root.GenZshCompletion(os.Stdout)
if err != nil {
log.Fatal(err)
fs.Fatal(nil, fmt.Sprint(err))
}
return
}
@@ -47,12 +48,12 @@ If output_file is "-", then the output will be written to stdout.
}
outFile, err := os.Create(out)
if err != nil {
log.Fatal(err)
fs.Fatal(nil, fmt.Sprint(err))
}
defer func() { _ = outFile.Close() }()
err = cmd.Root.GenZshCompletion(outFile)
if err != nil {
log.Fatal(err)
fs.Fatal(nil, fmt.Sprint(err))
}
},
}