test(logging): add logtest.NewLogger (#1300)

Return a `Logger` and its recording `Handler` together, so tests no longer need the two-line setup.

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

Assisted-by: Codet
Co-authored-by: bircni <[email protected]>
Reviewed-on: https://gitea.com/gitea/runner/pulls/1300
Reviewed-by: bircni <[email protected]>
This commit is contained in:
Lunny Xiaoandbircni committed 2026-10-11 23:47:50 +00:00
1 parent de961b91eb
commit 3bc5cc03f8
7 files changed
+21 -32

No files matched your search

+1 -2
View File
@@ -92,8 +92,7 @@ func frameOf(t *testing.T, pc uintptr) runtime.Frame {
}
func TestCallerPC(t *testing.T) {
h := logtest.New()
l := logging.New(h)
l, h := logtest.NewLogger()
l.Infof("method")
l.Info("method")
for _, r := range h.AllRecords() {