Skip to content

Commit

Permalink
feat(log): WithPrefixMessage func
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Jan 30, 2025
1 parent 471511f commit 7860571
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions log/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ func UpdateContext(ctx context.Context, f func(logger *Logger) *Logger) context.
return AttachLoggerToContext(ctx, f(GetLoggerFromContextOrDefault(ctx)))
}

func WithPrefixMessage(ctx context.Context, prefix string) context.Context {
return UpdateContext(ctx, func(logger *Logger) *Logger {
return logger.AppendPrefixMessage(prefix)
})
}

func Tracefc(ctx context.Context, format string, args ...any) {
getLoggerFromContextOrDefault(ctx).Debugf(format, args...)
}
Expand Down

0 comments on commit 7860571

Please sign in to comment.