mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-04 14:35:32 +00:00
Add `act/common/logging`: a printf-style `Logger` on a slog-shaped `Handler`, with a logrus-backed handler as the only backend, plus a `logtest` handler for tests. Move the job logger onto it: `common.Logger` returns `*logging.Logger`, the job log formatters and the `Reporter` hook become handlers, and composite step IDs travel in the context. Logging is tightly coupled to logrus types (hooks, formatters, `Entry.Data`). Going through our own interface first lets the remaining call sites move over with unchanged behavior, and lets the backend be swapped for `log/slog` in one place afterwards. The global process logger and its masking formatter stay on logrus for now. Assisted-by: Codet Co-authored-by: bircni <[email protected]> Reviewed-on: https://gitea.com/gitea/runner/pulls/1295 Reviewed-by: bircni <[email protected]>
19 lines
516 B
Go
19 lines
516 B
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package run
|
|
|
|
import (
|
|
"gitea.com/gitea/runner/act/common/logging"
|
|
)
|
|
|
|
// 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 handler.
|
|
type NullLogger struct{}
|
|
|
|
// WithJobLogger returns a handler that discards all logs.
|
|
func (n NullLogger) WithJobLogger() logging.Handler {
|
|
return logging.DiscardHandler
|
|
}
|