Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Expose Log writer that can be used with external libraries (#22)
Browse files Browse the repository at this point in the history
* Flinkk8soperator needs Log writer to be passed to
  • Loading branch information
anandswaminathan authored Jun 11, 2019
1 parent 2e30704 commit 755b546
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package logger

import (
"context"
"io"

"github.com/lyft/flytestdlib/contextutils"

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 755b546

Please sign in to comment.