31 lines
713 B
C#
31 lines
713 B
C#
using System.Collections.Concurrent;
|
|
using System.Collections.Generic;
|
|
|
|
namespace EonaCat.Logger.EonaCatCoreLogger
|
|
{
|
|
public class LoggerScopedContext
|
|
{
|
|
private readonly ConcurrentDictionary<string, string> _context = new();
|
|
|
|
public void Set(string key, string value)
|
|
{
|
|
_context[key] = value;
|
|
}
|
|
|
|
public string Get(string key)
|
|
{
|
|
return _context.TryGetValue(key, out var value) ? value : null;
|
|
}
|
|
|
|
public IReadOnlyDictionary<string, string> GetAll()
|
|
{
|
|
return new Dictionary<string, string>(_context);
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
_context.Clear();
|
|
}
|
|
}
|
|
}
|