mirror of
https://gitea.com/gitea/act_runner.git
synced 2024-11-25 06:16:13 +00:00
1735b26e66
We wanted the ability to disable outputting the logs from the individual job to the console. This changes the logging so that job logs are only output to the console whenever debug logging is enabled in `act_runner`, while still allowing the `Reporter` to receive these logs and forward them to Gitea when debug logging is not enabled. Co-authored-by: Rowan Bohde <rowan.bohde@gmail.com> Reviewed-on: https://gitea.com/gitea/act_runner/pulls/543 Reviewed-by: Jason Song <i@wolfogre.com> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: rowan-allspice <rowan-allspice@noreply.gitea.com> Co-committed-by: rowan-allspice <rowan-allspice@noreply.gitea.com>
25 lines
588 B
Go
25 lines
588 B
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package run
|
|
|
|
import (
|
|
"io"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// NullLogger is used to create a new JobLogger to discard logs. This
|
|
// will prevent these logs from being logged to the stdout, but
|
|
// forward them to the Reporter via its hook.
|
|
type NullLogger struct{}
|
|
|
|
// WithJobLogger creates a new logrus.Logger that will discard all logs.
|
|
func (n NullLogger) WithJobLogger() *log.Logger {
|
|
logger := log.New()
|
|
logger.SetOutput(io.Discard)
|
|
logger.SetLevel(log.TraceLevel)
|
|
|
|
return logger
|
|
}
|