1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-30 02:40:33 +00:00
strimertul/log/attr.go
2024-03-16 01:20:15 +01:00

17 lines
320 B
Go

package log
import (
"fmt"
"log/slog"
"runtime"
)
func Error(err error) slog.Attr {
pc, filename, line, _ := runtime.Caller(1)
return slog.Group("error",
slog.String("message", err.Error()),
slog.String("file", fmt.Sprintf("%s@%d", filename, line)),
slog.String("func", runtime.FuncForPC(pc).Name()),
)
}