Initial version

This commit is contained in:
2026-02-27 21:12:55 +01:00
parent d2bbbd8bc7
commit a73beb6ed5
184 changed files with 90370 additions and 63 deletions

View File

@@ -0,0 +1,60 @@
using EonaCat.LogStack.Configuration;
using EonaCat.LogStack.LogClient.Models;
using System;
using System.Collections.Generic;
namespace EonaCat.LogStack.LogClient
{
public class LogCentralEonaCatAdapter : IDisposable
{
private readonly LogCentralClient _client;
private LogBuilder _logBuilder;
public LogCentralEonaCatAdapter(LogBuilder logBuilder, LogCentralClient client)
{
_client = client;
_logBuilder.OnLog += LogSettings_OnLog;
}
private void LogSettings_OnLog(object sender, LogMessage e)
{
var entry = new LogEntry
{
Level = (int)MapLogLevel(e.Level),
Category = e.Category ?? "General",
Message = e.Message,
Properties = new Dictionary<string, object>
{
{ "Source", e.Origin ?? "Unknown" }
}
};
if (e.Exception != null)
{
entry.Exception = e.Exception.ToString();
entry.StackTrace = e.Exception.StackTrace;
}
_client.LogAsync(entry).ConfigureAwait(false);
}
private static LogLevel MapLogLevel(Core.LogLevel logType)
{
return logType switch
{
Core.LogLevel.Trace => LogLevel.Trace,
Core.LogLevel.Debug => LogLevel.Debug,
Core.LogLevel.Information => LogLevel.Information,
Core.LogLevel.Warning => LogLevel.Warning,
Core.LogLevel.Error => LogLevel.Error,
Core.LogLevel.Critical => LogLevel.Critical,
_ => LogLevel.Information
};
}
public void Dispose()
{
_logBuilder.OnLog -= LogSettings_OnLog;
GC.SuppressFinalize(this);
}
}
}