From dc299cc8adda5c9fb7a0f6a7719f3e2cd0f1f443 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Sun, 2 Oct 2022 11:36:05 +0200 Subject: logging: substitute %w for %v Subsitute the format specifier %w for %v in the logging facility. The logging functions use a fmt.Sprintf call behind the scene which does not recognize %w. %w should be used in fmt.Errorf when you want to wrap errors. Hence, the log entries that use %w are improperly formatted like this: ERROR 2022/10/02 09:13:57.724529 worker.go:439: could not get message info %!w(*fmt.wrapError=&{could not get structure: [snip] }) ^ Links: https://go.dev/blog/go1.13-errors Signed-off-by: Koni Marti Acked-by: Moritz Poldrack --- widgets/msgviewer.go | 2 +- widgets/terminal.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'widgets') diff --git a/widgets/msgviewer.go b/widgets/msgviewer.go index d5d1d279..126bf85b 100644 --- a/widgets/msgviewer.go +++ b/widgets/msgviewer.go @@ -667,7 +667,7 @@ func (pv *PartViewer) attemptCopy() { // if it's binary we have to rely on the filter to be sane _, err := io.Copy(pv.sink, pv.source) if err != nil { - logging.Warnf("failed to copy: %w", err) + logging.Warnf("failed to copy: %v", err) } } pv.sink.Close() diff --git a/widgets/terminal.go b/widgets/terminal.go index 894bdf09..b854a288 100644 --- a/widgets/terminal.go +++ b/widgets/terminal.go @@ -84,7 +84,7 @@ func (term *Terminal) Draw(ctx *ui.Context) { term.vterm.Watch(term) attr := &syscall.SysProcAttr{Setsid: true, Setctty: true, Ctty: 1} if err := term.vterm.StartWithAttrs(term.cmd, attr); err != nil { - logging.Errorf("error running terminal: %w", err) + logging.Errorf("error running terminal: %v", err) term.Close(err) return } -- cgit