Skip to content

Commit

Permalink
chore: fix log attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ucpr committed Jul 7, 2024
1 parent 3eac29f commit 4bb8f0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ func main() {

streamer, err := injectStreamer(ctx)
if err != nil {
log.Panic("Failed to inject streamer", err)
log.Panic("Failed to inject streamer", log.Ferror(err))
}
srv, err := injectServer(ctx)
if err != nil {
log.Panic("Failed to inject server", err)
log.Panic("Failed to inject server", log.Ferror(err))
}

go func() {
if err := srv.Serve(); err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Error("Failed to start http server", err)
log.Error("Failed to start http server", log.Ferror(err))
}
}()

Expand All @@ -48,10 +48,10 @@ func main() {
tctx, cancel := context.WithTimeout(context.Background(), gracefulShutdownTimeout)
defer cancel()
if err := srv.Shutdown(tctx); err != nil {
log.Error("Failed to shutdown http server", err)
log.Error("Failed to shutdown http server", log.Ferror(err))
}
if err := streamer.Close(tctx); err != nil {
log.Error("Failed to close change stream", err)
log.Error("Failed to close change stream", log.Ferror(err))
}

log.Info("Successfully graceful shutdown")
Expand Down
16 changes: 8 additions & 8 deletions pkg/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func toLogLevel(level slog.Level) slog.Value {

// Debug logs a debug message.
func Debug(msg string, attrs ...any) {
DebugContext(context.Background(), msg, attrs)
DebugContext(context.Background(), msg, attrs...)
}

// DebugContext logs a debug message with a context.
Expand All @@ -136,7 +136,7 @@ func DebugContext(ctx context.Context, msg string, attrs ...any) {

// Info logs an info message.
func Info(msg string, attrs ...any) {
InfoContext(context.Background(), msg, attrs)
InfoContext(context.Background(), msg, attrs...)
}

// InfoContext logs an info message with a context.
Expand All @@ -146,7 +146,7 @@ func InfoContext(ctx context.Context, msg string, attrs ...any) {

// Notice logs a notice message.
func Notice(msg string, attrs ...any) {
NoticeContext(context.Background(), msg, attrs)
NoticeContext(context.Background(), msg, attrs...)
}

// NoticeContext logs a notice message with a context.
Expand All @@ -156,7 +156,7 @@ func NoticeContext(ctx context.Context, msg string, attrs ...any) {

// Warn logs a warning message.
func Warn(msg string, attrs ...any) {
WarnContext(context.Background(), msg, attrs)
WarnContext(context.Background(), msg, attrs...)
}

// WarnContext logs a warning message with a context.
Expand All @@ -166,7 +166,7 @@ func WarnContext(ctx context.Context, msg string, attrs ...any) {

// Error logs an error message.
func Error(msg string, attrs ...any) {
ErrorContext(context.Background(), msg, attrs)
ErrorContext(context.Background(), msg, attrs...)
}

// ErrorContext logs an error message with a context.
Expand All @@ -176,7 +176,7 @@ func ErrorContext(ctx context.Context, msg string, attrs ...any) {

// Critical logs a critical message.
func Critical(msg string, attrs ...any) {
CriticalContext(context.Background(), msg, attrs)
CriticalContext(context.Background(), msg, attrs...)
}

// CriticalContext logs a critical message with a context.
Expand All @@ -186,7 +186,7 @@ func CriticalContext(ctx context.Context, msg string, attrs ...any) {

// Panic logs a critical message and panics.
func Panic(msg string, attrs ...any) {
PanicContext(context.Background(), msg, attrs)
PanicContext(context.Background(), msg, attrs...)
panic(msg)
}

Expand All @@ -198,7 +198,7 @@ func PanicContext(ctx context.Context, msg string, attrs ...any) {

// Fatal logs a critical message and exits.
func Fatal(msg string, attrs ...any) {
FatalContext(context.Background(), msg, attrs)
FatalContext(context.Background(), msg, attrs...)
os.Exit(1)
}

Expand Down

0 comments on commit 4bb8f0e

Please sign in to comment.