mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-27 05:38:55 +00:00
b30a7d1e19
* Fix typos and inconsistencies * igoimports * Gazelle
26 lines
638 B
Go
26 lines
638 B
Go
// Package logutil creates a Multi writer instance that
|
|
// write all logs that are written to stdout.
|
|
package logutil
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// ConfigurePersistentLogging adds a log-to-file writer. File content is identical to stdout.
|
|
func ConfigurePersistentLogging(logFileName string) error {
|
|
logrus.WithField("logFileName", logFileName).Info("Logs will be made persistent")
|
|
f, err := os.OpenFile(logFileName, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
mw := io.MultiWriter(os.Stdout, f)
|
|
logrus.SetOutput(mw)
|
|
|
|
logrus.Info("File logging initialized")
|
|
return nil
|
|
}
|