mirror of
https://github.com/Caraxi/mare.client.git
synced 2026-02-18 04:37:41 +01:00
update to api9
This commit is contained in:
parent
99f8060798
commit
f89f6c1216
33 changed files with 94 additions and 163 deletions
|
|
@ -1,4 +1,4 @@
|
|||
using Dalamud.Logging;
|
||||
using Dalamud.Plugin.Services;
|
||||
using MareSynchronos.MareConfiguration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text;
|
||||
|
|
@ -8,12 +8,14 @@ namespace MareSynchronos.Interop;
|
|||
internal sealed class DalamudLogger : ILogger
|
||||
{
|
||||
private readonly MareConfigService _mareConfigService;
|
||||
private readonly IPluginLog _pluginLog;
|
||||
private readonly string _name;
|
||||
|
||||
public DalamudLogger(string name, MareConfigService mareConfigService)
|
||||
public DalamudLogger(string name, MareConfigService mareConfigService, IPluginLog pluginLog)
|
||||
{
|
||||
_name = name;
|
||||
_mareConfigService = mareConfigService;
|
||||
_pluginLog = pluginLog;
|
||||
}
|
||||
|
||||
public IDisposable BeginScope<TState>(TState state) => default!;
|
||||
|
|
@ -28,18 +30,18 @@ internal sealed class DalamudLogger : ILogger
|
|||
if (!IsEnabled(logLevel)) return;
|
||||
|
||||
if ((int)logLevel <= (int)LogLevel.Information)
|
||||
PluginLog.Information($"[{_name}]{{{(int)logLevel}}} {state}");
|
||||
_pluginLog.Information($"[{_name}]{{{(int)logLevel}}} {state}");
|
||||
else
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
sb.AppendLine($"[{_name}]{{{(int)logLevel}}} {state}: {exception?.Message}");
|
||||
sb.AppendLine(exception?.StackTrace);
|
||||
if (logLevel == LogLevel.Warning)
|
||||
PluginLog.Warning(sb.ToString());
|
||||
_pluginLog.Warning(sb.ToString());
|
||||
else if (logLevel == LogLevel.Error)
|
||||
PluginLog.Error(sb.ToString());
|
||||
_pluginLog.Error(sb.ToString());
|
||||
else
|
||||
PluginLog.Fatal(sb.ToString());
|
||||
_pluginLog.Fatal(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue