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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
# User settings
*.DotSettings.user
*.sln.DotSettings

# JetBrains
.idea

# VSCode
.vscode
13 changes: 0 additions & 13 deletions .idea/.idea.CodeCargo.NatsDistributedCache/.idea/.gitignore

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/.idea.CodeCargo.NatsDistributedCache/.idea/vcs.xml

This file was deleted.

70 changes: 34 additions & 36 deletions src/CodeCargo.NatsDistributedCache/NatsCache.Log.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using Microsoft.Extensions.Logging;

namespace CodeCargo.NatsDistributedCache
namespace CodeCargo.NatsDistributedCache;

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

private void LogConnectionError(Exception exception)
{
_logger.LogError(EventIds.ConnectionError, exception, "Error connecting to NATS KV store.");
}

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 static class EventIds
{
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));
}

private void LogException(Exception exception)
{
_logger.LogError(EventIds.Exception, exception, "An exception occurred in NATS KV store.");
}

private void LogConnectionError(Exception exception)
{
_logger.LogError(EventIds.ConnectionError, exception, "Error connecting to NATS KV store.");
}

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);
}
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));
}
}
Loading
Loading