TimeFuncWithResult wraps a function call and logs its execution time, returning a result
(log *zap.Logger, funcName string, fn func() (T, error))
| 8 | |
| 9 | // TimeFuncWithResult wraps a function call and logs its execution time, returning a result |
| 10 | func TimeFuncWithResult[T any](log *zap.Logger, funcName string, fn func() (T, error)) (T, error) { |
| 11 | start := time.Now() |
| 12 | defer func() { |
| 13 | duration := time.Since(start).Milliseconds() |
| 14 | log.Debug(funcName+" executed", zap.Int64("duration_ms", duration)) |
| 15 | }() |
| 16 | return fn() |
| 17 | } |
no outgoing calls
no test coverage detected