Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 11 additions & 30 deletions src/CodeCargo.NatsDistributedCache/NatsCache.Log.cs
Original file line number Diff line number Diff line change
@@ -1,43 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Extensions.Logging;

namespace CodeCargo.NatsDistributedCache;

public partial class NatsCache
{
private void LogException(Exception exception)
{
_logger.LogError(EventIds.Exception, exception, "An exception occurred in NATS KV store.");
}
private void LogException(Exception exception) =>
_logger.LogError(EventIds.Exception, exception, "Exception in NatsCache");

private void LogConnectionError(Exception exception)
{
_logger.LogError(EventIds.ConnectionError, exception, "Error connecting to NATS KV store.");
}
private void LogConnected(string bucketName) =>
_logger.LogInformation(EventIds.Connected, "Connected to NATS KV bucket {bucketName}", bucketName);

private void LogConnectionIssue()
{
_logger.LogWarning(EventIds.ConnectionIssue, "Connection issue with NATS KV store.");
}

private void LogConnected()
{
_logger.LogInformation(EventIds.Connected, "Connected to NATS KV store.");
}

private void LogUpdateFailed(string key)
{
_logger.LogDebug(EventIds.UpdateFailed, "Sliding expiration update failed for key {Key} due to optimistic concurrency control", key);
}
private void LogUpdateFailed(string key) => _logger.LogDebug(
EventIds.UpdateFailed,
"Sliding expiration update failed for key {Key} due to optimistic concurrency control",
key);

private static class EventIds
{
public static readonly EventId ConnectionIssue = new EventId(100, nameof(ConnectionIssue));
public static readonly EventId ConnectionError = new EventId(101, nameof(ConnectionError));
public static readonly EventId Connected = new EventId(102, nameof(Connected));
public static readonly EventId UpdateFailed = new EventId(103, nameof(UpdateFailed));
public static readonly EventId Exception = new EventId(104, nameof(Exception));
public static readonly EventId Connected = new(100, nameof(Connected));
public static readonly EventId UpdateFailed = new(101, nameof(UpdateFailed));
public static readonly EventId Exception = new(102, nameof(Exception));
}
}
Loading