fix: Fixes socket disconnect on block. Fixes debug logging (#1031)
This commit is contained in:
parent
9bbcb4b274
commit
ef883b2872
5 changed files with 30 additions and 42 deletions
|
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||
using System.Runtime.CompilerServices;
|
||||
using Server.ContextMenus;
|
||||
using Server.Items;
|
||||
using Server.Logging;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -177,6 +178,8 @@ namespace Server
|
|||
|
||||
public class Item : IHued, IComparable<Item>, ISpawnable, IPropertyListObject
|
||||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(Item));
|
||||
|
||||
public const int QuestItemHue = 0x4EA; // Hmmmm... "for EA"?
|
||||
public static readonly List<Item> EmptyItems = new();
|
||||
private static readonly Queue<Item> m_DeltaQueue = new();
|
||||
|
|
@ -3277,9 +3280,7 @@ namespace Server
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Process Delta Queue for {0} failed: {1}", item, ex);
|
||||
#endif
|
||||
logger.Debug(ex, "Process Delta Queue for {Item} failed", item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2021 - ModernUO Development Team *
|
||||
* Copyright 2019-2022 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: LogFactory.cs *
|
||||
* *
|
||||
|
|
@ -16,16 +16,18 @@
|
|||
using System;
|
||||
using Serilog;
|
||||
|
||||
namespace Server.Logging
|
||||
{
|
||||
public static class LogFactory
|
||||
{
|
||||
private static readonly Serilog.ILogger serilogLogger = new LoggerConfiguration()
|
||||
.WriteTo.Async(a => a.Console(
|
||||
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} <s:{SourceContext}>{NewLine}{Exception}"
|
||||
))
|
||||
.CreateLogger();
|
||||
namespace Server.Logging;
|
||||
|
||||
public static ILogger GetLogger(Type declaringType) => new SerilogLogger(serilogLogger.ForContext(declaringType));
|
||||
}
|
||||
public static class LogFactory
|
||||
{
|
||||
private static readonly Serilog.ILogger serilogLogger = new LoggerConfiguration()
|
||||
.WriteTo.Async(a => a.Console(
|
||||
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} <s:{SourceContext}>{NewLine}{Exception}"
|
||||
))
|
||||
#if DEBUG
|
||||
.MinimumLevel.Debug()
|
||||
#endif
|
||||
.CreateLogger();
|
||||
|
||||
public static ILogger GetLogger(Type declaringType) => new SerilogLogger(serilogLogger.ForContext(declaringType));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,9 +70,7 @@ namespace Server
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine(ex);
|
||||
#endif
|
||||
logger.Debug(ex, "Failed to load map definition {MapDefName} ({MapDefId})", def.Name, def.Id);
|
||||
failures.Add($"\tInvalid map definition {def.Name} ({def.Id})");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7908,9 +7908,7 @@ namespace Server
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Process Delta Queue for {0} failed: {1}", mob, ex);
|
||||
#endif
|
||||
logger.Debug(ex, "Process Delta Queue for {Mobile} failed", mob);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -516,9 +516,6 @@ public partial class NetState : IComparable<NetState>
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine(ex);
|
||||
#endif
|
||||
TraceException(ex);
|
||||
Disconnect("Exception while sending.");
|
||||
}
|
||||
|
|
@ -861,18 +858,14 @@ public partial class NetState : IComparable<NetState>
|
|||
}
|
||||
catch (SocketException ex)
|
||||
{
|
||||
// Socket exceptions are generally ok, just spammy
|
||||
#if DEBUG
|
||||
Console.WriteLine(ex);
|
||||
#endif
|
||||
|
||||
Disconnect(string.Empty);
|
||||
if (ex.SocketErrorCode != SocketError.WouldBlock)
|
||||
{
|
||||
logger.Debug(ex, "Disconnected due to socket exception");
|
||||
Disconnect(string.Empty);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine(ex);
|
||||
#endif
|
||||
Disconnect($"Disconnected with error: {ex}");
|
||||
TraceException(ex);
|
||||
}
|
||||
|
|
@ -910,19 +903,15 @@ public partial class NetState : IComparable<NetState>
|
|||
}
|
||||
catch (SocketException ex)
|
||||
{
|
||||
#if DEBUG
|
||||
if (ex.ErrorCode != 54 && ex.ErrorCode != 89 && ex.ErrorCode != 995)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
#endif
|
||||
if (ex.ErrorCode is not 54 and not 89 and not 995)
|
||||
{
|
||||
logger.Debug(ex, "Disconnected due to a socket exception");
|
||||
}
|
||||
|
||||
Disconnect(string.Empty);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine(ex);
|
||||
#endif
|
||||
Disconnect($"Disconnected with error: {ex}");
|
||||
TraceException(ex);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue