mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
termstatus: use errWriter instead of os.Stderr
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/terminal"
|
"github.com/restic/restic/internal/terminal"
|
||||||
@@ -128,7 +127,7 @@ func (t *Terminal) run(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, err := io.WriteString(dst, msg.line); err != nil {
|
if _, err := io.WriteString(dst, msg.line); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "write failed: %v\n", err)
|
_, _ = fmt.Fprintf(t.errWriter, "write failed: %v\n", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +163,7 @@ func (t *Terminal) writeStatus(status []string) {
|
|||||||
|
|
||||||
_, err := t.wr.Write([]byte(line))
|
_, err := t.wr.Write([]byte(line))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "write failed: %v\n", err)
|
_, _ = fmt.Fprintf(t.errWriter, "write failed: %v\n", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,14 +189,14 @@ func (t *Terminal) runWithoutStatus(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, err := io.WriteString(dst, msg.line); err != nil {
|
if _, err := io.WriteString(dst, msg.line); err != nil {
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "write failed: %v\n", err)
|
_, _ = fmt.Fprintf(t.errWriter, "write failed: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
case stat := <-t.status:
|
case stat := <-t.status:
|
||||||
for _, line := range stat.lines {
|
for _, line := range stat.lines {
|
||||||
// Ensure that each message ends with exactly one newline.
|
// Ensure that each message ends with exactly one newline.
|
||||||
if _, err := fmt.Fprintln(t.wr, strings.TrimRight(line, "\n")); err != nil {
|
if _, err := fmt.Fprintln(t.wr, strings.TrimRight(line, "\n")); err != nil {
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "write failed: %v\n", err)
|
_, _ = fmt.Fprintf(t.errWriter, "write failed: %v\n", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user