diff --git a/logger/logger.go b/logger/logger.go index 3d8eccc..f1c8475 100644 --- a/logger/logger.go +++ b/logger/logger.go @@ -5,6 +5,7 @@ package logger import ( "context" + "io" "github.com/lyft/flytestdlib/contextutils" @@ -81,6 +82,12 @@ func getLogger(ctx context.Context) logrus.FieldLogger { return entry } +// Returns a standard io.PipeWriter that logs using the same logger configurations in this package. +func GetLogWriter(ctx context.Context) *io.PipeWriter { + logger := getLogger(ctx) + return logger.(*logrus.Entry).Writer() +} + func WithIndent(ctx context.Context, additionalIndent string) context.Context { indentLevel := getIndent(ctx) + additionalIndent return context.WithValue(ctx, indentLevelKey, indentLevel)