fix: don't log job output when level <= Info
This commit is contained in:
parent
65ed62d2f5
commit
233bf92f9b
2 changed files with 21 additions and 0 deletions
internal/app/run
17
internal/app/run/logging.go
Normal file
17
internal/app/run/logging.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package run
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type NullLogger struct {}
|
||||
|
||||
func (n NullLogger) WithJobLogger() *log.Logger {
|
||||
logger := log.New()
|
||||
logger.SetOutput(io.Discard)
|
||||
logger.SetLevel(log.TraceLevel)
|
||||
|
||||
return logger
|
||||
}
|
|
@ -223,6 +223,10 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.
|
|||
// add logger recorders
|
||||
ctx = common.WithLoggerHook(ctx, reporter)
|
||||
|
||||
if log.GetLevel() <= log.InfoLevel {
|
||||
ctx = runner.WithJobLoggerFactory(ctx, NullLogger{})
|
||||
}
|
||||
|
||||
execErr := executor(ctx)
|
||||
reporter.SetOutputs(job.Outputs)
|
||||
return execErr
|
||||
|
|
Loading…
Add table
Reference in a new issue