setup parser

This commit is contained in:
Gitea
2023-12-09 00:33:12 +03:00
parent 20107503e0
commit 3733278d8c
24 changed files with 986 additions and 100 deletions

View File

@ -34,6 +34,10 @@ func LogError(ctx context.Context, log *slog.Logger, msg string, attrs ...slog.A
log.LogAttrs(ctx, slog.LevelError, msg, append(attrs, getLogFields(ctx)...)...)
}
func LogWithError(ctx context.Context, log *slog.Logger, err error, msg string, attrs ...slog.Attr) {
LogError(ctx, log, msg, append(attrs, slog.Any("err", err))...)
}
func getLogFields(ctx context.Context) []slog.Attr {
store, _ := ctx.Value(ctxLogKey{}).(ctxLogAttrStore)
return store.attrs