initial commit

This commit is contained in:
Matthias Heil
2026-04-04 13:30:13 +02:00
commit 6bed9b284c
186 changed files with 10650 additions and 0 deletions
@@ -0,0 +1,24 @@
using System.Drawing;
using Microsoft.Extensions.Logging;
namespace LogViewer.Core;
public class DataStoreLoggerConfiguration
{
#region Properties
public EventId EventId { get; set; }
public Dictionary<LogLevel, LogEntryColor> Colors { get; } = new()
{
[LogLevel.Trace] = new() { Foreground = Color.DarkGray },
[LogLevel.Debug] = new() { Foreground = Color.Gray },
[LogLevel.Information] = new(),
[LogLevel.Warning] = new() { Foreground = Color.Orange},
[LogLevel.Error] = new() { Foreground = Color.White, Background = Color.OrangeRed },
[LogLevel.Critical] = new() { Foreground=Color.White, Background = Color.Red },
[LogLevel.None] = new(),
};
#endregion
}
@@ -0,0 +1,9 @@
using System.Collections.ObjectModel;
namespace LogViewer.Core;
public interface ILogDataStore
{
ObservableCollection<LogModel> Entries { get; }
void AddEntry(LogModel logModel);
}
@@ -0,0 +1,6 @@
namespace LogViewer.Core;
public interface ILogDataStoreImpl
{
public ILogDataStore DataStore { get; }
}
@@ -0,0 +1,32 @@
using System.Collections.ObjectModel;
namespace LogViewer.Core;
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
}
@@ -0,0 +1,10 @@
using System.Drawing;
namespace LogViewer.Core;
public class LogEntryColor
{
public Color Foreground { get; set; } = Color.Black;
public Color Background { get; set; } = Color.Transparent;
}
@@ -0,0 +1,22 @@
using Microsoft.Extensions.Logging;
namespace LogViewer.Core;
public class LogModel
{
#region Properties
public DateTime Timestamp { get; set; }
public LogLevel LogLevel { get; set; }
public EventId EventId { get; set; }
public object? State { get; set; }
public string? Exception { get; set; }
public LogEntryColor? Color { get; set; }
#endregion
}