mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-08-08 04:45:02 +02:00
feat: allow existing logger from context (#898)
We should reuse an existing context logger if in test context. This will allow test to setup act with a null logger to assert log messages. Co-authored-by: Markus Wolf <[email protected]> Co-authored-by: Markus Wolf <[email protected]>
This commit is contained in:
co-authored by
Markus Wolf
parent
f7263399b9
commit
6517d04b9a
@@ -48,6 +48,12 @@ func WithJobLogger(ctx context.Context, jobName string, secrets map[string]strin
|
||||
nextColor++
|
||||
|
||||
logger := logrus.New()
|
||||
if common.TestContext(ctx) {
|
||||
fieldLogger := common.Logger(ctx)
|
||||
if fieldLogger != nil {
|
||||
logger = fieldLogger.(*logrus.Logger)
|
||||
}
|
||||
}
|
||||
logger.SetFormatter(formatter)
|
||||
logger.SetOutput(os.Stdout)
|
||||
logger.SetLevel(logrus.GetLevel())
|
||||
|
||||
Reference in New Issue
Block a user