Updated
This commit is contained in:
@@ -1,11 +1,18 @@
|
|||||||
using System.Collections.Concurrent;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace EonaCat.Logger.EonaCatCoreLogger
|
namespace EonaCat.Logger.EonaCatCoreLogger
|
||||||
{
|
{
|
||||||
public class LoggerScopedContext
|
public class LoggerScopedContext : IDisposable
|
||||||
{
|
{
|
||||||
private readonly ConcurrentDictionary<string, string> _context = new();
|
private readonly ConcurrentDictionary<string, string> _context = new();
|
||||||
|
private readonly string _correlationId;
|
||||||
|
|
||||||
|
public LoggerScopedContext(string correlationId = null)
|
||||||
|
{
|
||||||
|
_correlationId = correlationId;
|
||||||
|
}
|
||||||
|
|
||||||
public void Set(string key, string value)
|
public void Set(string key, string value)
|
||||||
{
|
{
|
||||||
@@ -26,5 +33,15 @@ namespace EonaCat.Logger.EonaCatCoreLogger
|
|||||||
{
|
{
|
||||||
_context.Clear();
|
_context.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IDisposable CreateScope()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user