Files
platform/pkg/logs/logs.go

27 lines
424 B
Go
Raw Normal View History

2025-03-18 10:13:57 +08:00
package logs
import (
"log/slog"
"os"
"platform/pkg/env"
2025-03-18 10:13:57 +08:00
"time"
"github.com/lmittmann/tint"
)
func Init() {
2025-03-18 17:57:07 +08:00
slog.SetDefault(slog.New(
2025-03-18 10:13:57 +08:00
tint.NewHandler(os.Stdout, &tint.Options{
Level: env.LogLevel,
TimeFormat: time.Kitchen,
2025-03-18 17:57:07 +08:00
ReplaceAttr: func(_ []string, attr slog.Attr) slog.Attr {
err, ok := attr.Value.Any().(error)
if ok {
return tint.Err(err)
}
return attr
},
2025-03-18 10:13:57 +08:00
}),
2025-03-18 17:57:07 +08:00
))
2025-03-18 10:13:57 +08:00
}