Skip to content

Commit

Permalink
chore: improve slog
Browse files Browse the repository at this point in the history
  • Loading branch information
sysulq committed Dec 25, 2024
1 parent e2f4225 commit 067f3f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 47 deletions.
10 changes: 5 additions & 5 deletions internal/kslog/slog.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
// LogWithContext returns a logger with trace information.
func LogWithContext(ctx context.Context, logger *slog.Logger) *slog.Logger {
s := trace.SpanContextFromContext(ctx)
if s.HasTraceID() {
logger = logger.With(slog.String("trace_id", s.TraceID().String()))
}
if s.HasSpanID() {
logger = logger.With(slog.String("span_id", s.SpanID().String()))
if s.IsValid() {
logger = logger.With(
slog.String("span_id", s.SpanID().String()),
slog.String("trace_id", s.TraceID().String()),
)

Check warning on line 21 in internal/kslog/slog.go

View check run for this annotation

Codecov / codecov/patch

internal/kslog/slog.go#L18-L21

Added lines #L18 - L21 were not covered by tests
}

return logger
Expand Down
42 changes: 0 additions & 42 deletions internal/kslog/slog_level.go

This file was deleted.

0 comments on commit 067f3f6

Please sign in to comment.