feat: add logger class

This commit is contained in:
Anna 2021-04-28 23:57:29 -04:00
parent 9bfb7dc12e
commit 4b14302bf7
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
6 changed files with 36 additions and 10 deletions

View File

@ -66,7 +66,7 @@ namespace XivCommon.Functions {
try { try {
return this.AddBattleTalkDetourInner(uiModule, senderPtr, messagePtr, duration, style); return this.AddBattleTalkDetourInner(uiModule, senderPtr, messagePtr, duration, style);
} catch (Exception ex) { } catch (Exception ex) {
PluginLog.LogError(ex, "Exception in BattleTalk detour"); Logger.LogError(ex, "Exception in BattleTalk detour");
} }
Return: Return:
@ -89,7 +89,7 @@ namespace XivCommon.Functions {
try { try {
this.OnBattleTalk?.Invoke(ref sender, ref message, ref options, ref handled); this.OnBattleTalk?.Invoke(ref sender, ref message, ref options, ref handled);
} catch (Exception ex) { } catch (Exception ex) {
PluginLog.Log(ex, "Exception in BattleTalk event"); Logger.LogError(ex, "Exception in BattleTalk event");
} }
if (handled) { if (handled) {

View File

@ -89,7 +89,7 @@ namespace XivCommon.Functions {
try { try {
this.OpenChatBubbleDetourInner(manager, actor, text, a4); this.OpenChatBubbleDetourInner(manager, actor, text, a4);
} catch (Exception ex) { } catch (Exception ex) {
PluginLog.LogError(ex, "Exception in chat bubble detour"); Logger.LogError(ex, "Exception in chat bubble detour");
this.OpenChatBubbleHook!.Original(manager, actor, text, a4); this.OpenChatBubbleHook!.Original(manager, actor, text, a4);
} }
} }
@ -104,7 +104,7 @@ namespace XivCommon.Functions {
try { try {
this.OnChatBubble?.Invoke(ref actor, ref text); this.OnChatBubble?.Invoke(ref actor, ref text);
} catch (Exception ex) { } catch (Exception ex) {
PluginLog.LogError(ex, "Exception in chat bubble event"); Logger.LogError(ex, "Exception in chat bubble event");
} }
var newText = text.Encode().Terminate(); var newText = text.Encode().Terminate();
@ -120,7 +120,7 @@ namespace XivCommon.Functions {
try { try {
this.UpdateChatBubbleDetourInner(bubble, actor, a3); this.UpdateChatBubbleDetourInner(bubble, actor, a3);
} catch (Exception ex) { } catch (Exception ex) {
PluginLog.LogError(ex, "Exception in update chat bubble detour"); Logger.LogError(ex, "Exception in update chat bubble detour");
this.UpdateChatBubbleHook!.Original(bubble, actor, a3); this.UpdateChatBubbleHook!.Original(bubble, actor, a3);
} }
} }
@ -132,7 +132,7 @@ namespace XivCommon.Functions {
try { try {
this.OnUpdateBubble?.Invoke(ref actor); this.OnUpdateBubble?.Invoke(ref actor);
} catch (Exception ex) { } catch (Exception ex) {
PluginLog.LogError(ex, "Exception in chat bubble update event"); Logger.LogError(ex, "Exception in chat bubble update event");
} }
this.UpdateChatBubbleHook!.Original(bubble, actor.Address, a3); this.UpdateChatBubbleHook!.Original(bubble, actor.Address, a3);

View File

@ -121,7 +121,7 @@ namespace XivCommon.Functions {
this.JoinParty?.Invoke(listing); this.JoinParty?.Invoke(listing);
} }
} catch (Exception ex) { } catch (Exception ex) {
PluginLog.LogError(ex, "Exception in PF join detour"); Logger.LogError(ex, "Exception in PF join detour");
} }
return ret; return ret;

View File

@ -77,7 +77,7 @@ namespace XivCommon.Functions {
try { try {
this.AddonTalkV45DetourInner(data); this.AddonTalkV45DetourInner(data);
} catch (Exception ex) { } catch (Exception ex) {
PluginLog.LogError(ex, "Exception in Talk detour"); Logger.LogError(ex, "Exception in Talk detour");
} }
Return: Return:
@ -95,7 +95,7 @@ namespace XivCommon.Functions {
try { try {
this.OnTalk?.Invoke(ref name, ref text, ref style); this.OnTalk?.Invoke(ref name, ref text, ref style);
} catch (Exception ex) { } catch (Exception ex) {
PluginLog.LogError(ex, "Exception in Talk event"); Logger.LogError(ex, "Exception in Talk event");
} }
var newName = name.Encode().Terminate(); var newName = name.Encode().Terminate();

26
XivCommon/Logger.cs Executable file
View File

@ -0,0 +1,26 @@
using System;
using Dalamud.Plugin;
namespace XivCommon {
internal static class Logger {
private static string Format(string msg) {
return $"[XIVCommon] {msg}";
}
internal static void Log(string msg) {
PluginLog.Log(Format(msg));
}
internal static void LogWarning(string msg) {
PluginLog.LogWarning(Format(msg));
}
internal static void LogError(string msg) {
PluginLog.LogError(Format(msg));
}
internal static void LogError(Exception ex, string msg) {
PluginLog.LogError(ex, Format(msg));
}
}
}

View File

@ -29,7 +29,7 @@ namespace XivCommon {
} }
internal static void PrintMissingSig(string name) { internal static void PrintMissingSig(string name) {
PluginLog.LogWarning($"Could not find signature for {name}. This functionality will be disabled."); Logger.LogWarning($"Could not find signature for {name}. This functionality will be disabled.");
} }
} }
} }