loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: correct logging if caller has generics (#7121)

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7121
Reviewed-by: Otto <otto@codeberg.org>

Otto ed85d1f2 e4a21a14

+28 -1
+1 -1
modules/log/logger_impl.go
··· 191 191 if ok { 192 192 fn := runtime.FuncForPC(pc) 193 193 if fn != nil { 194 - event.Caller = fn.Name() + "()" 194 + event.Caller = strings.TrimSuffix(fn.Name(), "[...]") + "()" 195 195 } 196 196 } 197 197 event.Filename, event.Line = strings.TrimPrefix(filename, projectPackagePrefix), line
+27
modules/log/logger_impl_test.go
··· 1 + // Copyright 2025 The Forgejo Authors. All rights reserved. 2 + // SPDX-License-Identifier: GPL-3.0-or-later 3 + 4 + package log 5 + 6 + import ( 7 + "testing" 8 + 9 + "github.com/stretchr/testify/assert" 10 + ) 11 + 12 + func testGeneric[T any](log *LoggerImpl, t T) { 13 + log.Log(0, INFO, "Just testing the logging of a generic function %v", t) 14 + } 15 + 16 + func TestLog(t *testing.T) { 17 + bufferWriter := NewEventWriterBuffer("test-buffer", WriterMode{ 18 + Level: INFO, 19 + }) 20 + 21 + logger := NewLoggerWithWriters(t.Context(), "test", bufferWriter) 22 + 23 + testGeneric(logger, "I'm the generic value!") 24 + logger.Close() 25 + 26 + assert.Contains(t, bufferWriter.Buffer.String(), ".../logger_impl_test.go:13:testGeneric() [I] Just testing the logging of a generic function I'm the generic value!") 27 + }