refactor(logging): use the logging package for the remaining act log calls (#1301)

Move the global logrus calls left in `act` onto `logging`, and add `SetOutput` and `Output` for tests that capture the process logger. Behavior is unchanged.

Stacked on https://gitea.com/gitea/runner/pulls/1300.

Assisted-by: Codet
Co-authored-by: bircni <[email protected]>
Reviewed-on: https://gitea.com/gitea/runner/pulls/1301
Reviewed-by: bircni <[email protected]>
This commit is contained in:
Lunny Xiaoandbircni committed 2026-10-11 23:55:02 +00:00
1 parent 3bc5cc03f8
commit 76110557ab
9 files changed
+87 -75

No files matched your search

+11 -1
View File
@@ -3,7 +3,11 @@
package logging
import "github.com/sirupsen/logrus"
import (
"io"
"github.com/sirupsen/logrus"
)
var std = New(NewLogrusHandler(logrus.StandardLogger()))
@@ -16,6 +20,12 @@ func SetLevel(level Level) { logrus.SetLevel(toLogrusLevel(level)) }
// GetLevel returns the minimum level of the process-wide Logger.
func GetLevel() Level { return fromLogrusLevel(logrus.GetLevel()) }
// SetOutput sets where the process-wide Logger writes.
func SetOutput(w io.Writer) { logrus.SetOutput(w) }
// Output returns where the process-wide Logger writes.
func Output() io.Writer { return logrus.StandardLogger().Out }
func Enabled(level Level) bool { return std.Enabled(level) }
func With(args ...any) *Logger { return std.With(args...) }
+3 -3
View File
@@ -100,13 +100,13 @@ func TestCallerPC(t *testing.T) {
}
std := logrus.StandardLogger()
prevOut, prevCaller, prevHooks := std.Out, std.ReportCaller, std.ReplaceHooks(logrus.LevelHooks{})
prevOut, prevCaller, prevHooks := logging.Output(), std.ReportCaller, std.ReplaceHooks(logrus.LevelHooks{})
t.Cleanup(func() {
std.SetOutput(prevOut)
logging.SetOutput(prevOut)
std.SetReportCaller(prevCaller)
std.ReplaceHooks(prevHooks)
})
std.SetOutput(io.Discard)
logging.SetOutput(io.Discard)
std.SetReportCaller(true)
hook := logrustest.NewGlobal()
logging.Infof("global")