Skip to content

Commit b54ef73

Browse files
committed
Refactored logging methods to use more descriptive names for improved clarity
1 parent e3b9b22 commit b54ef73

File tree

5 files changed

+102
-92
lines changed

5 files changed

+102
-92
lines changed

TLibrary/Helpers/Unturned/UChatHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static void SendCommandReply(this IPlugin plugin, object toPlayer, string
6161
player.SteamPlayer());
6262
}
6363
else
64-
plugin.GetLogger().LogRichCommand(plugin.Localize(false, translation, args));
64+
plugin.GetLogger().RichCommand(plugin.Localize(false, translation, args));
6565
}
6666

6767
/// <summary>
@@ -79,7 +79,7 @@ public static void SendPlainCommandReply(this IPlugin plugin, object toPlayer, s
7979
else if (toPlayer is UnturnedPlayer player)
8080
ServerSendChatMessage(FormatHelper.FormatTextV2(string.Format(translation, args)), icon, null, player.SteamPlayer());
8181
else
82-
plugin.GetLogger().LogRichCommand(string.Format(translation, args));
82+
plugin.GetLogger().RichCommand(string.Format(translation, args));
8383
}
8484

8585
/// <summary>

TLibrary/Managers/DatabaseManagerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public MySqlConnection CreateConnection()
4545
}
4646
catch (Exception ex)
4747
{
48-
_plugin.GetLogger().LogException(ex.ToString());
48+
_plugin.GetLogger().Exception(ex.ToString());
4949
}
5050
return mySqlConnection;
5151
}

TLibrary/Managers/HookManager.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ public void Load(Type type)
2929
{
3030
if (!typeof(Hook).IsAssignableFrom(type))
3131
{
32-
_logger.LogException("'{0}' is not a hook.");
32+
_logger.Exception("'{0}' is not a hook.");
3333
return;
3434
}
3535

3636
if (type.IsAbstract)
3737
{
38-
_logger.LogException($"Cannot register {type.Name} because it is abstract.");
38+
_logger.Exception($"Cannot register {type.Name} because it is abstract.");
3939
return;
4040
}
4141

4242
var hook = CreateInstance<Hook>(type);
4343
if (_hooks.ContainsKey(hook.Name))
4444
{
45-
_logger.LogException("Hook with '{0}' name already exists.");
45+
_logger.Exception("Hook with '{0}' name already exists.");
4646
return;
4747
}
4848

@@ -64,7 +64,7 @@ public void LoadAll(Assembly pluginAssembly, bool ignoreDuplicate = false)
6464
{
6565
if (_hooks.ContainsKey(hook.Name))
6666
{
67-
_logger.LogException($"Hook with '{hook.Name}' name already exists.");
67+
_logger.Exception($"Hook with '{hook.Name}' name already exists.");
6868
continue;
6969
}
7070

@@ -80,8 +80,8 @@ public void LoadAll(Assembly pluginAssembly, bool ignoreDuplicate = false)
8080
}
8181
catch (Exception ex)
8282
{
83-
_logger.LogException($"Failed to add the '{hook.Name}' hook to the library.");
84-
_logger.LogError(ex);
83+
_logger.Exception($"Failed to add the '{hook.Name}' hook to the library.");
84+
_logger.Error(ex);
8585
}
8686
}
8787
}
@@ -94,20 +94,20 @@ public void Unload(Type type)
9494
{
9595
if (type != typeof(Hook))
9696
{
97-
_logger.LogException($"'{type.Name}' is not a hook.");
97+
_logger.Exception($"'{type.Name}' is not a hook.");
9898
return;
9999
}
100100

101101
if (!_hooks.Any(x => x.Value.GetType() == type))
102102
{
103-
_logger.LogException($"'{type.Name}' is not loaded.");
103+
_logger.Exception($"'{type.Name}' is not loaded.");
104104
return;
105105
}
106106

107107
var hook = _hooks.Values.FirstOrDefault(x => x.GetType() == type);
108108
if (hook == null)
109109
{
110-
_logger.LogException($"'{type.Name}' is not found.");
110+
_logger.Exception($"'{type.Name}' is not found.");
111111
return;
112112
}
113113

@@ -186,8 +186,8 @@ private T CreateInstance<T>(Type type)
186186
}
187187
catch (Exception ex)
188188
{
189-
_logger.LogException($"Failed to create instance for '{type.Name}' hook.");
190-
_logger.LogError(ex);
189+
_logger.Exception($"Failed to create instance for '{type.Name}' hook.");
190+
_logger.Error(ex);
191191
return default;
192192
}
193193
}

TLibrary/Models/Hooks/Hook.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ internal void Load()
5050
}
5151
catch (Exception ex)
5252
{
53-
Plugin.GetLogger().LogError($"Failed to load '{Name}' hook.");
54-
Plugin.GetLogger().LogException(ex.ToString());
53+
Plugin.GetLogger().Error($"Failed to load '{Name}' hook.");
54+
Plugin.GetLogger().Exception(ex.ToString());
5555
}
5656
}
5757

@@ -69,8 +69,8 @@ internal void Unload()
6969
catch (Exception ex)
7070
{
7171
IsLoaded = false;
72-
Plugin.GetLogger().LogError($"Failed to unload '{Name}' hook.");
73-
Plugin.GetLogger().LogException(ex.ToString());
72+
Plugin.GetLogger().Error($"Failed to unload '{Name}' hook.");
73+
Plugin.GetLogger().Exception(ex.ToString());
7474
}
7575
}
7676

0 commit comments

Comments
 (0)