From e1ba10a86e36d1ddfb2b47ab87e72b92a8f66ad7 Mon Sep 17 00:00:00 2001 From: Dimitrios Slamaris Date: Tue, 12 Nov 2024 12:42:54 +0100 Subject: [PATCH] bisync: fix output capture restoring the wrong output for logrus Before this change, if rclone is used as a library and logrus is used after a call to rc `sync/bisync`, logging does not work anymore and leads to writing to a closed pipe. This change restores the output correctly. Fixes #8158 --- cmd/bisync/bilib/output.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cmd/bisync/bilib/output.go b/cmd/bisync/bilib/output.go index ccd85c125..c35abde86 100644 --- a/cmd/bisync/bilib/output.go +++ b/cmd/bisync/bilib/output.go @@ -5,20 +5,13 @@ import ( "bytes" "log" - "github.com/rclone/rclone/fs" "github.com/sirupsen/logrus" ) // CaptureOutput runs a function capturing its output. func CaptureOutput(fun func()) []byte { logSave := log.Writer() - logrusSave := logrus.StandardLogger().Writer() - defer func() { - err := logrusSave.Close() - if err != nil { - fs.Errorf(nil, "error closing logrusSave: %v", err) - } - }() + logrusSave := logrus.StandardLogger().Out buf := &bytes.Buffer{} log.SetOutput(buf) logrus.SetOutput(buf)