diff --git a/clients/cache/redis.go b/clients/cache/redis.go index a37f368..fd850ca 100644 --- a/clients/cache/redis.go +++ b/clients/cache/redis.go @@ -46,7 +46,11 @@ func (rc *RedisCache) Set( value []byte, expiration time.Duration, ) error { - rc.Logger.Trace().Msgf("setting value in redis, key: %v, value: %v, expiration: %v", key, value, expiration) + rc.Logger.Trace(). + Str("key", key). + Str("value", string(value)). + Dur("expiration", expiration). + Msg("setting value in redis") return rc.client.Set(ctx, key, value, expiration).Err() } @@ -56,26 +60,38 @@ func (rc *RedisCache) Get( ctx context.Context, key string, ) ([]byte, error) { - rc.Logger.Trace().Msgf("getting value from redis, key: %v", key) + rc.Logger.Trace(). + Str("key", key). + Msg("getting value from redis") val, err := rc.client.Get(ctx, key).Bytes() if err == redis.Nil { - rc.Logger.Trace().Msgf("value not found in redis, key: %v", key) + rc.Logger.Trace(). + Str("key", key). + Msgf("value not found in redis") return nil, ErrNotFound } if err != nil { - rc.Logger.Error().Msgf("error during getting value from redis, key: %v, err: %v", key, err) + rc.Logger.Error(). + Str("key", key). + Err(err). + Msg("error during getting value from redis") return nil, err } - rc.Logger.Trace().Msgf("successfully got value from redis, key: %v, value: %v", key, val) + rc.Logger.Trace(). + Str("key", key). + Str("value", string(val)). + Msg("successfully got value from redis") return val, nil } // Delete deletes the value for the given key in the cache. func (rc *RedisCache) Delete(ctx context.Context, key string) error { - rc.Logger.Trace().Msgf("deleting value from redis, key: %v", key) + rc.Logger.Trace(). + Str("key", key). + Msg("deleting value from redis") return rc.client.Del(ctx, key).Err() }