drop warnf

This commit is contained in:
Michael Eischer 2025-09-18 22:52:56 +02:00
parent 7d5ebdd0b3
commit f71278138f
3 changed files with 6 additions and 11 deletions

View file

@ -2,6 +2,7 @@ package main
import (
"context"
"fmt"
"os"
"os/signal"
"syscall"
@ -23,7 +24,8 @@ func createGlobalContext() context.Context {
func cleanupHandler(c <-chan os.Signal, cancel context.CancelFunc) {
s := <-c
debug.Log("signal %v received, cleaning up", s)
Warnf("\rsignal %v received, cleaning up \n", s)
// ignore error as there's no good way to handle it
_, _ = fmt.Fprintf(os.Stderr, "\rsignal %v received, cleaning up \n", s)
if val, _ := os.LookupEnv("RESTIC_DEBUG_STACKTRACE_SIGINT"); val != "" {
_, _ = os.Stderr.WriteString("\n--- STACKTRACE START ---\n\n")

View file

@ -197,15 +197,6 @@ func collectBackends() *location.Registry {
return backends
}
// Warnf writes the message to the configured stderr stream.
func Warnf(format string, args ...interface{}) {
_, err := fmt.Fprintf(globalOptions.stderr, format, args...)
if err != nil {
fmt.Fprintf(os.Stderr, "unable to write to stderr: %v\n", err)
}
debug.Log(format, args...)
}
// resolvePassword determines the password to be used for opening the repository.
func resolvePassword(opts *GlobalOptions, envStr string) (string, error) {
if opts.PasswordFile != "" && opts.PasswordCommand != "" {

View file

@ -141,7 +141,9 @@ func printExitError(code int, message string) {
err := json.NewEncoder(globalOptions.stderr).Encode(jsonS)
if err != nil {
Warnf("JSON encode failed: %v\n", err)
// ignore error as there's no good way to handle it
_, _ = fmt.Fprintf(os.Stderr, "JSON encode failed: %v\n", err)
debug.Log("JSON encode failed: %v\n", err)
return
}
} else {