Skip to content

Commit d1bff45

Browse files
committed
use [LoggerMessage] for logging
1 parent 9b091e2 commit d1bff45

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Caching/StackExchangeRedis/src/RedisOutputCacheStore.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,23 @@ private async Task RunGarbageCollectionLoopAsync()
114114
catch (Exception ex)
115115
{
116116
// this sweep failed; log it
117-
_logger.LogWarning(ex, "Transient error occurred executing redis output-cache GC loop");
117+
RedisOutputCacheGCTransientFault(_logger, ex);
118118
}
119119
}
120120
}
121121
catch (Exception ex)
122122
{
123123
// the entire loop is dead
124-
_logger.LogError(ex, "Fatal error occurred executing redis output-cache GC loop");
124+
RedisOutputCacheGCFatalError(_logger, ex);
125125
}
126126
}
127127

128+
[LoggerMessage(1, LogLevel.Warning, "Transient error occurred executing redis output-cache GC loop.", EventName = "RedisOutputCacheGCTransientError")]
129+
internal static partial void RedisOutputCacheGCTransientFault(ILogger logger, Exception exception);
130+
131+
[LoggerMessage(2, LogLevel.Error, "Fatal error occurred executing redis output-cache GC loop.", EventName = "RedisOutputCacheGCFatalError")]
132+
internal static partial void RedisOutputCacheGCFatalError(ILogger logger, Exception exception);
133+
128134
internal async ValueTask<long?> ExecuteGarbageCollectionAsync(long keepValuesGreaterThan, CancellationToken cancellationToken = default)
129135
{
130136
var cache = await ConnectAsync(CancellationToken.None).ConfigureAwait(false);

0 commit comments

Comments
 (0)