feat(logging): Adds support for Serilog (#573)
Example:
```cs
public class SomeClass
{
private static ILogger _logger;
private static Logger => _logger ??= LogFactory.GetLogger(typeof(SomeClass));
...
}
```
This commit is contained in:
parent
5e1ec5416d
commit
3a619e0103
29 changed files with 347 additions and 176 deletions
|
|
@ -157,7 +157,7 @@ namespace Server.Network
|
|||
|
||||
if (check != null && check.Map != Map.Internal)
|
||||
{
|
||||
state.WriteConsole("Account in use");
|
||||
state.LogInfo("Account in use");
|
||||
state.SendPopupMessage(PMMessage.CharInWorld);
|
||||
return;
|
||||
}
|
||||
|
|
@ -274,7 +274,7 @@ namespace Server.Network
|
|||
|
||||
if (check != null && check.Map != Map.Internal && check != m)
|
||||
{
|
||||
state.WriteConsole("Account in use");
|
||||
state.LogInfo("Account in use");
|
||||
state.SendPopupMessage(PMMessage.CharInWorld);
|
||||
return;
|
||||
}
|
||||
|
|
@ -395,13 +395,13 @@ namespace Server.Network
|
|||
|
||||
if (!m_AuthIDWindow.TryGetValue(authID, out var ap))
|
||||
{
|
||||
state.WriteConsole("Invalid client detected, disconnecting...");
|
||||
state.LogInfo("Invalid client detected, disconnecting...");
|
||||
state.Disconnect("Unable to find auth id.");
|
||||
}
|
||||
|
||||
if (state._authId != 0 && authID != state._authId || state._authId == 0 && authID != state._seed)
|
||||
{
|
||||
state.WriteConsole("Invalid client detected, disconnecting...");
|
||||
state.LogInfo("Invalid client detected, disconnecting...");
|
||||
state.Disconnect("Invalid auth id in game login packet.");
|
||||
return;
|
||||
}
|
||||
|
|
@ -461,7 +461,7 @@ namespace Server.Network
|
|||
|
||||
if (state._seed == 0)
|
||||
{
|
||||
state.WriteConsole("Invalid client detected, disconnecting");
|
||||
state.LogInfo("Invalid client detected, disconnecting");
|
||||
state.Disconnect("Duplicate seed sent.");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ namespace Server.Network
|
|||
{
|
||||
if (state.Mobile == null)
|
||||
{
|
||||
state.WriteConsole(
|
||||
state.LogInfo(
|
||||
"Sent in-game packet (0xBFx{0:X2}) before having been attached to a mobile",
|
||||
packetId
|
||||
);
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ namespace Server.Network
|
|||
}
|
||||
default:
|
||||
{
|
||||
state.WriteConsole("Unknown text-command type 0x{0:X2}: {1}", state, type, command);
|
||||
state.LogInfo("Unknown text-command type 0x{0:X2}: {1}", state, type, command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -373,7 +373,7 @@ namespace Server.Network
|
|||
|
||||
if (!buttonExists)
|
||||
{
|
||||
state.WriteConsole("Invalid gump response, disconnecting...");
|
||||
state.LogInfo("Invalid gump response, disconnecting...");
|
||||
var exception = new InvalidGumpResponseException($"Button {buttonID} doesn't exist");
|
||||
exception.SetStackTrace(new StackTrace());
|
||||
NetState.TraceException(exception);
|
||||
|
|
@ -387,7 +387,7 @@ namespace Server.Network
|
|||
|
||||
if (switchCount < 0 || switchCount > gump.m_Switches)
|
||||
{
|
||||
state.WriteConsole("Invalid gump response, disconnecting...");
|
||||
state.LogInfo("Invalid gump response, disconnecting...");
|
||||
var exception = new InvalidGumpResponseException($"Bad switch count {switchCount}");
|
||||
exception.SetStackTrace(new StackTrace());
|
||||
NetState.TraceException(exception);
|
||||
|
|
@ -408,7 +408,7 @@ namespace Server.Network
|
|||
|
||||
if (textCount < 0 || textCount > gump.m_TextEntries)
|
||||
{
|
||||
state.WriteConsole("Invalid gump response, disconnecting...");
|
||||
state.LogInfo("Invalid gump response, disconnecting...");
|
||||
var exception = new InvalidGumpResponseException($"Bad text entry count {textCount}");
|
||||
exception.SetStackTrace(new StackTrace());
|
||||
NetState.TraceException(exception);
|
||||
|
|
@ -427,7 +427,7 @@ namespace Server.Network
|
|||
|
||||
if (textLength > 239)
|
||||
{
|
||||
state.WriteConsole("Invalid gump response, disconnecting...");
|
||||
state.LogInfo("Invalid gump response, disconnecting...");
|
||||
var exception = new InvalidGumpResponseException($"Text entry {i} is too long ({textLength})");
|
||||
exception.SetStackTrace(new StackTrace());
|
||||
NetState.TraceException(exception);
|
||||
|
|
@ -614,7 +614,7 @@ namespace Server.Network
|
|||
|
||||
if (ph.Ingame && state.Mobile == null)
|
||||
{
|
||||
state.WriteConsole(
|
||||
state.LogInfo(
|
||||
"Sent in-game packet (0xD7x{0:X2}) before being attached to a mobile",
|
||||
packetId
|
||||
);
|
||||
|
|
|
|||
|
|
@ -20,11 +20,14 @@ using System.IO.Compression;
|
|||
using System.Runtime.CompilerServices;
|
||||
using Server.Collections;
|
||||
using Server.Gumps;
|
||||
using Server.Logging;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
public static class OutgoingGumpPackets
|
||||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(OutgoingGumpPackets));
|
||||
|
||||
public static void SendCloseGump(this NetState ns, int typeId, int buttonId)
|
||||
{
|
||||
if (ns == null)
|
||||
|
|
@ -73,9 +76,7 @@ namespace Server.Network
|
|||
|
||||
if (error != ZlibError.Okay)
|
||||
{
|
||||
Utility.PushColor(ConsoleColor.Red);
|
||||
Core.WriteConsoleLine($"Gump compression failed {error}");
|
||||
Utility.PopColor();
|
||||
logger.Warning($"Gump compression failed {error}");
|
||||
|
||||
writer.Write(4);
|
||||
writer.Write(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue