strimertul/utils/deferlogger.go

18 lines
334 B
Go

package utils
import (
"io"
"log/slog"
"reflect"
"runtime/debug"
"git.sr.ht/~ashkeel/strimertul/log"
)
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())), log.Error(err))
}
}