strimertul/utils/deferlogger.go

16 lines
294 B
Go

package utils
import (
"io"
"log/slog"
"reflect"
"runtime/debug"
)
func Close(res io.Closer) {
err := res.Close()
if err != nil {
slog.Error("Could not close resource", slog.String("name", reflect.TypeOf(res).String()), slog.String("stack", string(debug.Stack())), "error", err)
}
}