log: WithLogger: remove redundant intermediate var

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-07-16 22:35:44 +02:00
parent 40ee5fb11b
commit 4a36022e20
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C

View File

@ -103,8 +103,7 @@ func SetFormat(format string) error {
// WithLogger returns a new context with the provided logger. Use in // WithLogger returns a new context with the provided logger. Use in
// combination with logger.WithField(s) for great effect. // combination with logger.WithField(s) for great effect.
func WithLogger(ctx context.Context, logger *logrus.Entry) context.Context { func WithLogger(ctx context.Context, logger *logrus.Entry) context.Context {
e := logger.WithContext(ctx) return context.WithValue(ctx, loggerKey{}, logger.WithContext(ctx))
return context.WithValue(ctx, loggerKey{}, e)
} }
// GetLogger retrieves the current logger from the context. If no logger is // GetLogger retrieves the current logger from the context. If no logger is