mirror of
https://github.com/rclone/rclone.git
synced 2024-11-26 02:09:55 +08:00
6210e22ab5
Fixes #118 Co-authored-by: Chris Nelson <stuff@cjnaz.com>
23 lines
458 B
Go
23 lines
458 B
Go
// Package bilib provides common stuff for bisync and bisync_test
|
|
package bilib
|
|
|
|
import (
|
|
"bytes"
|
|
"log"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// CaptureOutput runs a function capturing its output.
|
|
func CaptureOutput(fun func()) []byte {
|
|
logSave := log.Writer()
|
|
logrusSave := logrus.StandardLogger().Writer()
|
|
buf := &bytes.Buffer{}
|
|
log.SetOutput(buf)
|
|
logrus.SetOutput(buf)
|
|
fun()
|
|
log.SetOutput(logSave)
|
|
logrus.SetOutput(logrusSave)
|
|
return buf.Bytes()
|
|
}
|