* most of the groups refactoring on client * register OnMethods for group stuff * start implementing client (still pretty broken) * finish implementing new api first iteration * idk rework everything for pair shit (still WIP); goal is to remove PairedClients and GroupPairClients from ApiController * move everything to PairManager, remove dictionaries from APiController * remove admin stuff from client, cleanup * adjust reconnection handling, add new settings, todo still to remove access from old stuff that's marked obsolete from config * add back adding servers, fix intro ui * fix obsolete calls * adjust config namespace * add UI for setting animation/sound permissions to syncshells * add ConfigurationService to hot reload config on change from external * move transient data cache to configuration * add deleting service to ui * fix saving of transient resources * fix group pair user assignments * halt scanner when penumbra inactive, add visible/online/offline split to individual pairs and tags * add presence to syncshell ui * move fullpause from config to server config * fixes in code style * more codestyle * show info icon on player in shells, don't show icon when no changes from default state are made, add online notifs * fixes to intro UI --------- Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
107 lines
3.5 KiB
C#
107 lines
3.5 KiB
C#
using System.Diagnostics;
|
|
using Dalamud.Logging;
|
|
using Dalamud.Utility;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace MareSynchronos.Utils;
|
|
|
|
internal class Logger : ILogger
|
|
{
|
|
private readonly string _name;
|
|
|
|
public static void Info(string? info)
|
|
{
|
|
var caller = new StackTrace().GetFrame(1)?.GetMethod()?.ReflectedType?.Name ?? "Unknown";
|
|
PluginLog.Information($"[{caller}] {info}");
|
|
}
|
|
|
|
public static void Debug(string? debug, string stringToHighlight = "")
|
|
{
|
|
var caller = new StackTrace().GetFrame(1)?.GetMethod()?.ReflectedType?.Name ?? "Unknown";
|
|
if (debug != null && debug.Contains(stringToHighlight, StringComparison.Ordinal) && !stringToHighlight.IsNullOrEmpty())
|
|
{
|
|
PluginLog.Warning($"[{caller}] {debug}");
|
|
}
|
|
else
|
|
{
|
|
PluginLog.Debug($"[{caller}] {debug}");
|
|
}
|
|
}
|
|
|
|
public static void Error(string? msg, Exception ex)
|
|
{
|
|
var caller = new StackTrace().GetFrame(1)?.GetMethod()?.ReflectedType?.Name ?? "Unknown";
|
|
PluginLog.Error($"[{caller}] {msg} {Environment.NewLine} Exception: {ex.Message} {Environment.NewLine} {ex.StackTrace}");
|
|
}
|
|
|
|
public static void Warn(string? msg, Exception ex)
|
|
{
|
|
var caller = new StackTrace().GetFrame(1)?.GetMethod()?.ReflectedType?.Name ?? "Unknown";
|
|
PluginLog.Warning($"[{caller}] {msg} {Environment.NewLine} Exception: {ex.Message} {Environment.NewLine} {ex.StackTrace}");
|
|
}
|
|
|
|
public static void Error(string? msg)
|
|
{
|
|
var caller = new StackTrace().GetFrame(1)?.GetMethod()?.ReflectedType?.Name ?? "Unknown";
|
|
PluginLog.Error($"[{caller}] {msg}");
|
|
}
|
|
|
|
public static void Warn(string? warn)
|
|
{
|
|
var caller = new StackTrace().GetFrame(1)?.GetMethod()?.ReflectedType?.Name ?? "Unknown";
|
|
PluginLog.Warning($"[{caller}] {warn}");
|
|
}
|
|
|
|
public static void Verbose(string? verbose)
|
|
{
|
|
var caller = new StackTrace().GetFrame(1)?.GetMethod()?.ReflectedType?.Name ?? "Unknown";
|
|
#if DEBUG
|
|
PluginLog.Debug($"[{caller}] {verbose}");
|
|
#else
|
|
PluginLog.Verbose($"[{caller}] {verbose}");
|
|
#endif
|
|
}
|
|
|
|
public Logger(string name)
|
|
{
|
|
this._name = name;
|
|
}
|
|
|
|
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
|
|
{
|
|
if (!IsEnabled(logLevel)) return;
|
|
|
|
switch (logLevel)
|
|
{
|
|
case LogLevel.Debug:
|
|
PluginLog.Debug($"[{_name}] [{eventId}] {formatter(state, exception)}");
|
|
break;
|
|
case LogLevel.Error:
|
|
case LogLevel.Critical:
|
|
PluginLog.Error($"[{_name}] [{eventId}] {formatter(state, exception)}");
|
|
break;
|
|
case LogLevel.Information:
|
|
PluginLog.Information($"[{_name}] [{eventId}] {formatter(state, exception)}");
|
|
break;
|
|
case LogLevel.Warning:
|
|
PluginLog.Warning($"[{_name}] [{eventId}] {formatter(state, exception)}");
|
|
break;
|
|
case LogLevel.Trace:
|
|
default:
|
|
#if DEBUG
|
|
PluginLog.Verbose($"[{_name}] [{eventId}] {formatter(state, exception)}");
|
|
#else
|
|
PluginLog.Verbose($"[{name}] {eventId} {state} {formatter(state, exception)}");
|
|
#endif
|
|
break;
|
|
}
|
|
}
|
|
|
|
public bool IsEnabled(LogLevel logLevel)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public IDisposable BeginScope<TState>(TState state) => default!;
|
|
}
|