Skip to content

Commit

Permalink
Improve the logging system
Browse files Browse the repository at this point in the history
  • Loading branch information
VahidN committed Mar 30, 2024
1 parent 5979c60 commit de0ede6
Show file tree
Hide file tree
Showing 19 changed files with 527 additions and 367 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ charset = utf-8-bom
[*.cs]

dotnet_diagnostic.S3878.severity = suggestion
dotnet_diagnostic.S127.severity = suggestion
dotnet_diagnostic.S2857.severity = suggestion
dotnet_diagnostic.S2094.severity = suggestion

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.200",
"version": "8.0.202",
"rollForward": "latestMajor",
"allowPrerelease": true
}
Expand Down
16 changes: 5 additions & 11 deletions src/EFCoreSecondLevelCacheInterceptor/CacheableEventId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,18 @@ public static class CacheableEventId
/// <summary>
/// A query result is returned from cache.
/// </summary>
public static readonly EventId CacheHit = MakeQueryId(Id.CacheHit);
public static readonly EventId CacheHit = MakeQueryId(CacheableLogEventId.CacheHit);

/// <summary>
/// A query result is stored by the cache.
/// </summary>
public static readonly EventId QueryResultCached = MakeQueryId(Id.QueryResultCached);
public static readonly EventId QueryResultCached = MakeQueryId(CacheableLogEventId.QueryResultCached);

/// <summary>
/// A query result is removed from the cache.
/// </summary>
public static readonly EventId QueryResultInvalidated = MakeQueryId(Id.QueryResultInvalidated);
public static readonly EventId QueryResultInvalidated = MakeQueryId(CacheableLogEventId.QueryResultInvalidated);

private static EventId MakeQueryId(Id id) => new((int)id, _queryPrefix + id);

private enum Id
{
CacheHit = CacheableBaseId,
QueryResultCached,
QueryResultInvalidated,
}
private static EventId MakeQueryId(CacheableLogEventId id)
=> new((int)id, _queryPrefix + id);
}
62 changes: 62 additions & 0 deletions src/EFCoreSecondLevelCacheInterceptor/CacheableLogEventId.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
namespace EFCoreSecondLevelCacheInterceptor;

/// <summary>
/// Event IDs of the internal logged messages of the library
/// </summary>
public enum CacheableLogEventId
{
/// <summary>
/// It's not used
/// </summary>
None,

/// <summary>
/// The query result is returned from the cache.
/// </summary>
CacheHit = CacheableEventId.CacheableBaseId,

/// <summary>
/// The query result is stored in the cache.
/// </summary>
QueryResultCached,

/// <summary>
/// The query result was removed from the cache.
/// </summary>
QueryResultInvalidated,

/// <summary>
/// The query result was not cached due to some predefined setting.
/// </summary>
CachingSkipped,

/// <summary>
/// The query result was not remove from the cached due to some predefined setting.
/// </summary>
InvalidationSkipped,

/// <summary>
/// It will be fired when the current interceptor is instantiated for the first time.
/// </summary>
CachingSystemStarted,

/// <summary>
/// An exception has been occured
/// </summary>
CachingError,

/// <summary>
/// The query result was overwritten by the interceptor for the cache
/// </summary>
QueryResultSuppressed,

/// <summary>
/// It will be fired when the cache dependencies if the current query are calculated
/// </summary>
CacheDependenciesCalculated,

/// <summary>
/// It will be fired when the cache policy of the current query is calculated
/// </summary>
CachePolicyCalculated
}
Loading

0 comments on commit de0ede6

Please sign in to comment.