MCPcopy
hub / github.com/gofiber/fiber / withCapturedLogOutput

Function withCapturedLogOutput

services_test.go:48–67  ·  view source on GitHub ↗
(t *testing.T, writer io.Writer)

Source from the content-addressed store, hash-verified

46var servicesTestLogOutputMu sync.Mutex
47
48func withCapturedLogOutput(t *testing.T, writer io.Writer) {
49 t.Helper()
50
51 servicesTestLogOutputMu.Lock()
52 cleanupRegistered := false
53 defer func() {
54 if !cleanupRegistered {
55 servicesTestLogOutputMu.Unlock()
56 }
57 }()
58
59 currentOutput := log.DefaultLogger[*stdlog.Logger]().Logger().Writer()
60 t.Cleanup(func() {
61 log.SetOutput(currentOutput)
62 servicesTestLogOutputMu.Unlock()
63 })
64 cleanupRegistered = true
65
66 log.SetOutput(writer)
67}
68
69func (*shutdownHookStorage) GetWithContext(context.Context, string) ([]byte, error) {
70 return nil, nil

Callers 1

Test_InitServicesFunction · 0.85

Calls 5

DefaultLoggerFunction · 0.92
SetOutputFunction · 0.92
LockMethod · 0.65
UnlockMethod · 0.65
LoggerMethod · 0.65

Tested by

no test coverage detected