2026-04-04 13:30:13 +02:00
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
2026-04-05 10:13:12 +02:00
|
|
|
namespace Serilog.Sinks.LogView.Core.Logging;
|
2026-04-04 13:30:13 +02:00
|
|
|
|
|
|
|
|
public class LogDataStore : ILogDataStore
|
|
|
|
|
{
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
private static readonly SemaphoreSlim _semaphore = new(initialCount: 1);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<LogModel> Entries { get; } = new();
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Methods
|
|
|
|
|
|
|
|
|
|
public virtual void AddEntry(LogModel logModel)
|
|
|
|
|
{
|
|
|
|
|
// ensure only one operation at time from multiple threads
|
|
|
|
|
_semaphore.Wait();
|
|
|
|
|
|
|
|
|
|
Entries.Add(logModel);
|
|
|
|
|
|
|
|
|
|
_semaphore.Release();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|