mirror of
https://git.sr.ht/~ashkeel/strimertul
synced 2024-09-30 02:40:33 +00:00
18 lines
320 B
Go
18 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()),
|
||
|
)
|
||
|
}
|