mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 19:40:37 +00:00
3197748240
* Log streaming proof of concept * fix broken imports * imports Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
31 lines
797 B
Go
31 lines
797 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/prysmaticlabs/prysm/shared/params"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func addLogWriter(w io.Writer) {
|
|
mw := io.MultiWriter(logrus.StandardLogger().Out, w)
|
|
logrus.SetOutput(mw)
|
|
}
|
|
|
|
// 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, params.BeaconIoConfig().ReadWritePermissions)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
addLogWriter(f)
|
|
|
|
logrus.Info("File logging initialized")
|
|
return nil
|
|
}
|