mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-08 16:20:29 +00:00
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]>
43 lines
1.7 KiB
Go
43 lines
1.7 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package logging
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
var std = New(NewLogrusHandler(logrus.StandardLogger()))
|
|
|
|
// Default returns the process-wide Logger.
|
|
func Default() *Logger { return std }
|
|
|
|
// SetLevel sets the minimum level of the process-wide Logger.
|
|
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...) }
|
|
func WithError(err error) *Logger { return std.WithError(err) }
|
|
func Tracef(format string, args ...any) { std.logf(LevelTrace, format, args) }
|
|
func Debugf(format string, args ...any) { std.logf(LevelDebug, format, args) }
|
|
func Infof(format string, args ...any) { std.logf(LevelInfo, format, args) }
|
|
func Warnf(format string, args ...any) { std.logf(LevelWarn, format, args) }
|
|
func Errorf(format string, args ...any) { std.logf(LevelError, format, args) }
|
|
func Trace(args ...any) { std.log(LevelTrace, args) }
|
|
func Debug(args ...any) { std.log(LevelDebug, args) }
|
|
func Info(args ...any) { std.log(LevelInfo, args) }
|
|
func Warn(args ...any) { std.log(LevelWarn, args) }
|
|
func Error(args ...any) { std.log(LevelError, args) }
|