feat: allow existing logger from context (#859)
We should reuse an existing context logger if available. This will allow test to setup act with a null logger to assert log messages. Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se> Co-authored-by: Björn Brauer <bjoern.brauer@new-work.se>
This commit is contained in:
parent
cd24df5727
commit
603cf56878
1 changed files with 8 additions and 1 deletions
|
@ -47,7 +47,14 @@ func WithJobLogger(ctx context.Context, jobName string, secrets map[string]strin
|
|||
formatter.insecureSecrets = insecureSecrets
|
||||
nextColor++
|
||||
|
||||
logger := logrus.New()
|
||||
var logger *logrus.Logger
|
||||
fieldLogger := common.Logger(ctx)
|
||||
if fieldLogger != nil {
|
||||
logger = fieldLogger.(*logrus.Logger)
|
||||
}
|
||||
if logger == nil {
|
||||
logger = logrus.New()
|
||||
}
|
||||
logger.SetFormatter(formatter)
|
||||
logger.SetOutput(os.Stdout)
|
||||
logger.SetLevel(logrus.GetLevel())
|
||||
|
|
Loading…
Reference in a new issue