fix: Fixes structured logging (#1043)
- [X] Fixes various bugs in logging.
This commit is contained in:
parent
78bb4f4bb2
commit
6e69d25e33
31 changed files with 96 additions and 102 deletions
|
|
@ -54,13 +54,14 @@ public static class UOClient
|
||||||
{
|
{
|
||||||
logger.Information(
|
logger.Information(
|
||||||
CuoSettings?.ClientVersion == ServerClientVersion
|
CuoSettings?.ClientVersion == ServerClientVersion
|
||||||
? $"Automatically detected client version {ServerClientVersion} from CUO settings."
|
? "Automatically detected client version {ServerClientVersion} from CUO settings."
|
||||||
: $"Automatically detected client version {ServerClientVersion}"
|
: "Automatically detected client version {ServerClientVersion}",
|
||||||
|
ServerClientVersion
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Information($"Manually configured to use client version {ServerClientVersion}");
|
logger.Information("Manually configured to use client version {ServerClientVersion}", ServerClientVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ClientVersion DetectCUOClient()
|
private static ClientVersion DetectCUOClient()
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ public static class ServerConfiguration
|
||||||
|
|
||||||
if (File.Exists(m_FilePath))
|
if (File.Exists(m_FilePath))
|
||||||
{
|
{
|
||||||
logger.Information($"Reading server configuration from {_relPath}...");
|
logger.Information("Reading server configuration from {Path}...", _relPath);
|
||||||
m_Settings = JsonConfig.Deserialize<ServerSettings>(m_FilePath);
|
m_Settings = JsonConfig.Deserialize<ServerSettings>(m_FilePath);
|
||||||
|
|
||||||
if (m_Settings == null)
|
if (m_Settings == null)
|
||||||
|
|
|
||||||
|
|
@ -320,8 +320,7 @@ public sealed class Map : IComparable<Map>
|
||||||
public const int SectorShift = 4;
|
public const int SectorShift = 4;
|
||||||
public const int SectorActiveRange = 2;
|
public const int SectorActiveRange = 2;
|
||||||
|
|
||||||
private static ILogger _logger;
|
private static ILogger logger = LogFactory.GetLogger(typeof(Map));
|
||||||
private static ILogger Logger => _logger ??= LogFactory.GetLogger(typeof(Map));
|
|
||||||
|
|
||||||
private readonly int m_FileIndex;
|
private readonly int m_FileIndex;
|
||||||
private readonly Sector[][] m_Sectors;
|
private readonly Sector[][] m_Sectors;
|
||||||
|
|
@ -409,7 +408,7 @@ public sealed class Map : IComparable<Map>
|
||||||
{
|
{
|
||||||
if (this == Internal && m_Name != "Internal")
|
if (this == Internal && m_Name != "Internal")
|
||||||
{
|
{
|
||||||
Logger.Warning($"Internal map name was '{m_Name}'\n{new StackTrace()}");
|
logger.Warning("Internal map name was '{Name}'\n{StackTrace}", m_Name, new StackTrace());
|
||||||
m_Name = "Internal";
|
m_Name = "Internal";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -419,8 +418,7 @@ public sealed class Map : IComparable<Map>
|
||||||
{
|
{
|
||||||
if (this == Internal && value != "Internal")
|
if (this == Internal && value != "Internal")
|
||||||
{
|
{
|
||||||
Logger.Warning($"Attempted to set internal map name to '{value}'\n{new StackTrace()}");
|
logger.Warning("Attempted to set internal map name to '{Value}'\n{StackTrace}", value, new StackTrace());
|
||||||
|
|
||||||
value = "Internal";
|
value = "Internal";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1045,7 +1043,7 @@ public sealed class Map : IComparable<Map>
|
||||||
|
|
||||||
if (Regions.ContainsKey(regName))
|
if (Regions.ContainsKey(regName))
|
||||||
{
|
{
|
||||||
Logger.Warning($"Duplicate region name '{regName}' for map '{Name}'");
|
logger.Warning("Duplicate region name '{RegionName}' for map '{MapName}'", regName, Name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1101,7 +1099,7 @@ public sealed class Map : IComparable<Map>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.Warning($"Warning: Invalid object ({o}) in line of sight");
|
logger.Warning("Warning: Invalid object ({Object}) in line of sight", o);
|
||||||
p = Point3D.Zero;
|
p = Point3D.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,18 +80,18 @@ namespace Server
|
||||||
if (failures.Count > 0)
|
if (failures.Count > 0)
|
||||||
{
|
{
|
||||||
logger.Warning(
|
logger.Warning(
|
||||||
"Map Definitions loaded with failures ({0} maps, {1} failures) ({2:F2} seconds)",
|
"Map Definitions loaded with failures ({Count} maps, {FailureCount} failures) ({Duration:F2} seconds)",
|
||||||
count,
|
count,
|
||||||
failures.Count,
|
failures.Count,
|
||||||
stopwatch.Elapsed.TotalSeconds
|
stopwatch.Elapsed.TotalSeconds
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.Warning(string.Join(Environment.NewLine, failures));
|
logger.Warning("Map load failures: {Failure}", failures);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Information(
|
logger.Information(
|
||||||
"Map Definitions loaded successfully ({0} maps, {1} failures) ({2:F2} seconds)",
|
"Map Definitions loaded successfully ({Count} maps, {FailureCount} failures) ({Duration:F2} seconds)",
|
||||||
count,
|
count,
|
||||||
failures.Count,
|
failures.Count,
|
||||||
stopwatch.Elapsed.TotalSeconds
|
stopwatch.Elapsed.TotalSeconds
|
||||||
|
|
|
||||||
|
|
@ -5190,7 +5190,12 @@ namespace Server
|
||||||
|
|
||||||
if (oldAmount <= 0)
|
if (oldAmount <= 0)
|
||||||
{
|
{
|
||||||
logger.Error($"Item {item.GetType()} ({item.Serial}) has amount of {oldAmount}, but must be at least 1");
|
logger.Error(
|
||||||
|
"Item {Type} ({Serial}) has amount of {OldAmount}, but must be at least 1",
|
||||||
|
item.GetType(),
|
||||||
|
item.Serial,
|
||||||
|
oldAmount
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -343,13 +343,7 @@ public partial class NetState : IComparable<NetState>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void LogInfo(string text)
|
public void LogInfo(string text)
|
||||||
{
|
{
|
||||||
logger.Information("Client: {0}: {1}", this, text);
|
logger.Information("Client: {NetState}: {Message}", this, text);
|
||||||
}
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
public void LogInfo(string format, params object[] args)
|
|
||||||
{
|
|
||||||
LogInfo(string.Format(format, args));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddMenu(IMenu menu)
|
public void AddMenu(IMenu menu)
|
||||||
|
|
@ -861,7 +855,7 @@ public partial class NetState : IComparable<NetState>
|
||||||
{
|
{
|
||||||
if (ex.SocketErrorCode != SocketError.WouldBlock)
|
if (ex.SocketErrorCode != SocketError.WouldBlock)
|
||||||
{
|
{
|
||||||
logger.Debug(ex, "Disconnected due to socket exception");
|
logger.Debug(ex, "Disconnected due to a socket exception");
|
||||||
Disconnect(string.Empty);
|
Disconnect(string.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1127,13 +1121,6 @@ public partial class NetState : IComparable<NetState>
|
||||||
|
|
||||||
var count = TcpServer.Instances.Count;
|
var count = TcpServer.Instances.Count;
|
||||||
|
|
||||||
if (a != null)
|
LogInfo(a != null ? $"Disconnected. [{count} Online] [{a}]" : $"Disconnected. [{count} Online]");
|
||||||
{
|
|
||||||
LogInfo("Disconnected. [{0} Online] [{1}]", count, a);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogInfo("Disconnected. [{0} Online]", count);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,8 +103,7 @@ public static class IncomingExtendedCommandPackets
|
||||||
if (state.Mobile == null)
|
if (state.Mobile == null)
|
||||||
{
|
{
|
||||||
state.LogInfo(
|
state.LogInfo(
|
||||||
"Sent in-game packet (0xBFx{0:X2}) before having been attached to a mobile",
|
$"Sent in-game packet (0xBFx{packetId:X2}) before having been attached to a mobile"
|
||||||
packetId
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ public static class IncomingPlayerPackets
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
state.LogInfo("Unknown text-command type 0x{0:X2}: {1}", state, type, command);
|
state.LogInfo($"Unknown text-command type 0x{state:X2}: {type} ({command})");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public static class OutgoingGumpPackets
|
||||||
|
|
||||||
if (error != ZlibError.Okay)
|
if (error != ZlibError.Okay)
|
||||||
{
|
{
|
||||||
logger.Warning($"Gump compression failed {error}");
|
logger.Warning("Gump compression failed: {Error}", error);
|
||||||
|
|
||||||
writer.Write(4);
|
writer.Write(4);
|
||||||
writer.Write(0);
|
writer.Write(0);
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ namespace Server.Network
|
||||||
|
|
||||||
foreach (var ipep in listeningAddresses)
|
foreach (var ipep in listeningAddresses)
|
||||||
{
|
{
|
||||||
logger.Information("Listening: {0}:{1}", ipep.Address, ipep.Port);
|
logger.Information("Listening: {Address}:{Port}", ipep.Address, ipep.Port);
|
||||||
}
|
}
|
||||||
|
|
||||||
ListeningAddresses = listeningAddresses.ToArray();
|
ListeningAddresses = listeningAddresses.ToArray();
|
||||||
|
|
@ -119,12 +119,12 @@ namespace Server.Network
|
||||||
// WSAEADDRINUSE
|
// WSAEADDRINUSE
|
||||||
if (se.ErrorCode == 10048)
|
if (se.ErrorCode == 10048)
|
||||||
{
|
{
|
||||||
logger.Warning("Listener: {0}:{1}: Failed (In Use)", ipep.Address, ipep.Port);
|
logger.Warning("Listener: {Address}:{Port}: Failed (In Use)", ipep.Address, ipep.Port);
|
||||||
}
|
}
|
||||||
// WSAEADDRNOTAVAIL
|
// WSAEADDRNOTAVAIL
|
||||||
else if (se.ErrorCode == 10049)
|
else if (se.ErrorCode == 10049)
|
||||||
{
|
{
|
||||||
logger.Warning("Listener {0}:{1}: Failed (Unavailable)", ipep.Address, ipep.Port);
|
logger.Warning("Listener {Address}:{Port}: Failed (Unavailable)", ipep.Address, ipep.Port);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -142,7 +142,7 @@ namespace Server.Network
|
||||||
while (++count <= MaxConnectionsPerLoop && _connectedQueue.TryDequeue(out var ns))
|
while (++count <= MaxConnectionsPerLoop && _connectedQueue.TryDequeue(out var ns))
|
||||||
{
|
{
|
||||||
Instances.Add(ns);
|
Instances.Add(ns);
|
||||||
ns.LogInfo("Connected. [{0} Online]", Instances.Count);
|
ns.LogInfo($"Connected. [{Instances.Count} Online]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -166,7 +166,7 @@ namespace Server.Network
|
||||||
if (socket.RemoteEndPoint is IPEndPoint ipep)
|
if (socket.RemoteEndPoint is IPEndPoint ipep)
|
||||||
{
|
{
|
||||||
var ip = ipep.Address.ToString();
|
var ip = ipep.Address.ToString();
|
||||||
logger.Warning("Listener {0}: Failed (Maximum connections reached)", ip);
|
logger.Warning("Listener {Address}: Failed (Maximum connections reached)", ip);
|
||||||
NetState.TraceDisconnect("Maximum connections reached.", ip);
|
NetState.TraceDisconnect("Maximum connections reached.", ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ namespace Server
|
||||||
if (failures.Count == 0)
|
if (failures.Count == 0)
|
||||||
{
|
{
|
||||||
logger.Information(
|
logger.Information(
|
||||||
"Regions loaded ({0} regions, {1} failures) ({2:F2} seconds)",
|
"Regions loaded ({Count} regions, {FailureCount} failures) ({Duration:F2} seconds)",
|
||||||
count,
|
count,
|
||||||
failures.Count,
|
failures.Count,
|
||||||
stopwatch.Elapsed.TotalSeconds
|
stopwatch.Elapsed.TotalSeconds
|
||||||
|
|
@ -73,13 +73,13 @@ namespace Server
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Warning(
|
logger.Warning(
|
||||||
"Failed loading regions ({0} regions, {1} failures) ({2:F2} seconds)",
|
"Failed loading regions ({Count} regions, {FailureCount} failures) ({Duration:F2} seconds)",
|
||||||
count,
|
count,
|
||||||
failures.Count,
|
failures.Count,
|
||||||
stopwatch.Elapsed.TotalSeconds
|
stopwatch.Elapsed.TotalSeconds
|
||||||
);
|
);
|
||||||
|
|
||||||
logger.Warning(string.Join(Environment.NewLine, failures));
|
logger.Warning("{Failures}", failures);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ namespace Server
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Warning($"map{mapFileIndex}.mul was not found.");
|
logger.Warning("{File} was not found.", $"map{mapFileIndex}.mul");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,7 +103,7 @@ namespace Server
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Warning($"staidx{mapFileIndex}.mul was not found.");
|
logger.Warning("{File} was not found.", $"staidx{mapFileIndex}.mul");
|
||||||
}
|
}
|
||||||
|
|
||||||
var staticsPath = Core.FindDataFile($"statics{mapFileIndex}.mul", false);
|
var staticsPath = Core.FindDataFile($"statics{mapFileIndex}.mul", false);
|
||||||
|
|
@ -114,7 +114,7 @@ namespace Server
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Warning($"statics{fileIndex}.mul was not found.");
|
logger.Warning("{File} was not found.", $"statics{fileIndex}.mul");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,11 +46,11 @@ namespace Server
|
||||||
|
|
||||||
if (exception == null)
|
if (exception == null)
|
||||||
{
|
{
|
||||||
logger.Information("Maps loaded ({0:F2} seconds)", stopwatch.Elapsed.TotalSeconds);
|
logger.Information("Maps loaded ({Duration:F2} seconds)", stopwatch.Elapsed.TotalSeconds);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Error(exception, "Loading maps failed ({0:F2} seconds)", stopwatch.Elapsed.TotalSeconds);
|
logger.Error(exception, "Loading maps failed ({Duration:F2} seconds)", stopwatch.Elapsed.TotalSeconds);
|
||||||
throw exception;
|
throw exception;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ namespace Server
|
||||||
{
|
{
|
||||||
if (Running)
|
if (Running)
|
||||||
{
|
{
|
||||||
logger.Error($"Timer is returned while still running!\n{new StackTrace()}");
|
logger.Error("Timer is returned while still running!\n{StackTrace}", new StackTrace());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ namespace Server
|
||||||
if (_poolCount >= _poolCapacity)
|
if (_poolCount >= _poolCapacity)
|
||||||
{
|
{
|
||||||
#if DEBUG_TIMERS
|
#if DEBUG_TIMERS
|
||||||
logger.Warning($"DelayCallTimer pool reached maximum of {_poolCapacity} timers");
|
logger.Warning("DelayCallTimer pool reached maximum of {Capacity} timers", _poolCapacity);
|
||||||
_allowFinalization = true;
|
_allowFinalization = true;
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
|
@ -181,7 +181,7 @@ namespace Server
|
||||||
if (timer != null)
|
if (timer != null)
|
||||||
{
|
{
|
||||||
#if DEBUG_TIMERS
|
#if DEBUG_TIMERS
|
||||||
logger.Information($"Getting from pool: ({_poolCount} / {_poolCapacity})");
|
logger.Information("Getting from pool: ({Count} / {Capacity})", _poolCount, _poolCapacity);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
timer.Init(delay, interval, count);
|
timer.Init(delay, interval, count);
|
||||||
|
|
@ -197,7 +197,7 @@ namespace Server
|
||||||
_timerPoolDepletionAmount++;
|
_timerPoolDepletionAmount++;
|
||||||
|
|
||||||
#if DEBUG_TIMERS
|
#if DEBUG_TIMERS
|
||||||
logger.Warning($"Timer pool depleted and timer was allocated.\n{new StackTrace()}");
|
logger.Warning("Timer pool depleted and timer was allocated.\n{StackTrace}", new StackTrace());
|
||||||
#endif
|
#endif
|
||||||
return new DelayCallTimer(delay, interval, count, callback);
|
return new DelayCallTimer(delay, interval, count, callback);
|
||||||
}
|
}
|
||||||
|
|
@ -211,7 +211,7 @@ namespace Server
|
||||||
{
|
{
|
||||||
if (!_allowFinalization)
|
if (!_allowFinalization)
|
||||||
{
|
{
|
||||||
logger.Warning($"Pooled timer was not returned to the pool.\n{_stackTraces[GetHashCode()]}");
|
logger.Warning("Pooled timer was not returned to the pool.\n{StackTrace}", _stackTraces[GetHashCode()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,9 @@ namespace Server
|
||||||
var amountToRefill = Math.Min(_maxPoolCapacity, amountToGrow);
|
var amountToRefill = Math.Min(_maxPoolCapacity, amountToGrow);
|
||||||
|
|
||||||
var maximumHit = amountToGrow > amountToRefill ? " Maximum pool size has been reached." : "";
|
var maximumHit = amountToGrow > amountToRefill ? " Maximum pool size has been reached." : "";
|
||||||
|
var warningMessage = $"Timer pool depleted by {{Amount}}. Refilling with {{AmountRefill}}.{maximumHit}";
|
||||||
|
|
||||||
logger.Warning($"Timer pool depleted by {_timerPoolDepletionAmount}. Refilling with {amountToRefill}.{maximumHit}");
|
logger.Warning(warningMessage, _timerPoolDepletionAmount, amountToRefill);
|
||||||
RefillPoolAsync(amountToRefill);
|
RefillPoolAsync(amountToRefill);
|
||||||
_timerPoolDepletionAmount = 0;
|
_timerPoolDepletionAmount = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +63,7 @@ namespace Server
|
||||||
_poolHead = head;
|
_poolHead = head;
|
||||||
_poolCount += amount;
|
_poolCount += amount;
|
||||||
#if DEBUG_TIMERS
|
#if DEBUG_TIMERS
|
||||||
logger.Information($"Returning to pool. ({_poolCount} / {_poolCapacity})");
|
logger.Information("Returning to pool. ({Count} / {Capacity})", _poolCount, _poolCapacity);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,7 +85,7 @@ namespace Server
|
||||||
internal static void RefillPool(int amount, out DelayCallTimer head, out DelayCallTimer tail)
|
internal static void RefillPool(int amount, out DelayCallTimer head, out DelayCallTimer tail)
|
||||||
{
|
{
|
||||||
#if DEBUG_TIMERS
|
#if DEBUG_TIMERS
|
||||||
logger.Information($"Filling pool with {amount} timers.");
|
logger.Information("Filling pool with {Amount} timers.", amount);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
head = null;
|
head = null;
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,7 @@ namespace Server
|
||||||
|
|
||||||
// TODO: Handle timers > 17yrs
|
// TODO: Handle timers > 17yrs
|
||||||
#if DEBUG_TIMERS
|
#if DEBUG_TIMERS
|
||||||
logger.Error($"Timer is more than max duration. ({originalDelay})");
|
logger.Error("Timer is more than max duration. ({Duration})", originalDelay);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,12 +224,12 @@ namespace Server
|
||||||
while (t != null)
|
while (t != null)
|
||||||
{
|
{
|
||||||
var name = t.ToString();
|
var name = t.ToString();
|
||||||
|
|
||||||
hash.TryGetValue(name, out var count);
|
hash.TryGetValue(name, out var count);
|
||||||
hash[name] = count + 1;
|
hash[name] = count + 1;
|
||||||
|
|
||||||
total++;
|
total++;
|
||||||
|
|
||||||
t = t?._nextTimer;
|
t = t?._nextTimer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -284,11 +284,11 @@ namespace Server
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
|
|
||||||
logger.Information(string.Format("World loaded ({1} items, {2} mobiles) ({0:F2} seconds)",
|
logger.Information("World loaded ({ItemCount} items, {MobileCount} mobiles) ({Duration:F2} seconds)",
|
||||||
watch.Elapsed.TotalSeconds,
|
watch.Elapsed.TotalSeconds,
|
||||||
Items.Count,
|
Items.Count,
|
||||||
Mobiles.Count
|
Mobiles.Count
|
||||||
));
|
);
|
||||||
|
|
||||||
WorldState = WorldState.Running;
|
WorldState = WorldState.Running;
|
||||||
}
|
}
|
||||||
|
|
@ -304,7 +304,7 @@ namespace Server
|
||||||
{
|
{
|
||||||
if (_pendingAdd.ContainsKey(entity.Serial))
|
if (_pendingAdd.ContainsKey(entity.Serial))
|
||||||
{
|
{
|
||||||
logger.Warning("Entity {0} was both pending both deletion and addition after save", entity);
|
logger.Warning("Entity {Entity} was both pending both deletion and addition after save", entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveEntity(entity);
|
RemoveEntity(entity);
|
||||||
|
|
@ -402,7 +402,7 @@ namespace Server
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
|
|
||||||
logger.Information("Writing world save snapshot done ({0:F2} seconds)", watch.Elapsed.TotalSeconds);
|
logger.Information("Writing world save snapshot done ({Duration:F2} seconds)", watch.Elapsed.TotalSeconds);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -505,7 +505,7 @@ namespace Server
|
||||||
if (exception == null)
|
if (exception == null)
|
||||||
{
|
{
|
||||||
var duration = watch.Elapsed.TotalSeconds;
|
var duration = watch.Elapsed.TotalSeconds;
|
||||||
logger.Information("World save completed ({0:F2} seconds)", duration);
|
logger.Information("World save completed ({Duration:F2} seconds)", duration);
|
||||||
|
|
||||||
// Only broadcast if it took at least 150ms
|
// Only broadcast if it took at least 150ms
|
||||||
if (duration >= 0.15)
|
if (duration >= 0.15)
|
||||||
|
|
|
||||||
|
|
@ -22,14 +22,14 @@ namespace Server
|
||||||
|
|
||||||
if (Firewall.IsBlocked(ip))
|
if (Firewall.IsBlocked(ip))
|
||||||
{
|
{
|
||||||
logger.Information("Client: {0}: Firewall blocked connection attempt.", ip);
|
logger.Information("Client: {IP}: Firewall blocked connection attempt.", ip);
|
||||||
e.AllowConnection = false;
|
e.AllowConnection = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IPLimiter.SocketBlock && !IPLimiter.Verify(ip))
|
if (IPLimiter.SocketBlock && !IPLimiter.Verify(ip))
|
||||||
{
|
{
|
||||||
logger.Warning("Client: {0}: Past IP limit threshold", ip);
|
logger.Warning("Client: {IP}: Past IP limit threshold", ip);
|
||||||
|
|
||||||
using (var op = new StreamWriter("ipLimits.log", true))
|
using (var op = new StreamWriter("ipLimits.log", true))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ namespace Server.Misc
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
state.LogInfo("Deleting character {0} (0x{1:X})", index, m.Serial.Value);
|
state.LogInfo($"Deleting character {index} (0x{m.Serial.Value:X})");
|
||||||
|
|
||||||
acct.Comments.Add(new AccountComment("System", $"Character #{index + 1} {m} deleted by {state}"));
|
acct.Comments.Add(new AccountComment("System", $"Character #{index + 1} {m} deleted by {state}"));
|
||||||
|
|
||||||
|
|
@ -314,16 +314,16 @@ namespace Server.Misc
|
||||||
if (!CanCreate(state.Address))
|
if (!CanCreate(state.Address))
|
||||||
{
|
{
|
||||||
logger.Information(
|
logger.Information(
|
||||||
"Login: {0}: Account '{1}' not created, ip already has {2} account{3}.",
|
$"Login: {{NetState}} Account '{{Username}}' not created, ip already has {{AccountCount}} account{(MaxAccountsPerIP == 1 ? "" : "s")}.",
|
||||||
state,
|
state,
|
||||||
un,
|
un,
|
||||||
MaxAccountsPerIP,
|
MaxAccountsPerIP
|
||||||
MaxAccountsPerIP == 1 ? "" : "s"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Information("Login: {0}: Creating new account '{1}'", state, un);
|
logger.Information("Login: {NetState}: Creating new account '{Username}'", state, un);
|
||||||
|
|
||||||
var a = new Account(un, pw);
|
var a = new Account(un, pw);
|
||||||
|
|
||||||
|
|
@ -337,7 +337,7 @@ namespace Server.Misc
|
||||||
e.Accepted = false;
|
e.Accepted = false;
|
||||||
e.RejectReason = ALRReason.InUse;
|
e.RejectReason = ALRReason.InUse;
|
||||||
|
|
||||||
logger.Information("Login: {0}: Past IP limit threshold", e.State);
|
logger.Information("Login: {NetState}: Past IP limit threshold", e.State);
|
||||||
|
|
||||||
using var op = new StreamWriter("ipLimits.log", true);
|
using var op = new StreamWriter("ipLimits.log", true);
|
||||||
op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, Core.Now);
|
op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, Core.Now);
|
||||||
|
|
@ -365,28 +365,28 @@ namespace Server.Misc
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Information("Login: {0}: Invalid username '{1}'", e.State, un);
|
logger.Information("Login: {NetState} Invalid username '{Username}'", e.State, un);
|
||||||
e.RejectReason = ALRReason.Invalid;
|
e.RejectReason = ALRReason.Invalid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!acct.HasAccess(e.State))
|
else if (!acct.HasAccess(e.State))
|
||||||
{
|
{
|
||||||
logger.Information("Login: {0}: Access denied for '{1}'", e.State, un);
|
logger.Information("Login: {NetState} Access denied for '{Username}'", e.State, un);
|
||||||
e.RejectReason = LockdownLevel > AccessLevel.Player ? ALRReason.BadComm : ALRReason.BadPass;
|
e.RejectReason = LockdownLevel > AccessLevel.Player ? ALRReason.BadComm : ALRReason.BadPass;
|
||||||
}
|
}
|
||||||
else if (!acct.CheckPassword(pw))
|
else if (!acct.CheckPassword(pw))
|
||||||
{
|
{
|
||||||
logger.Information("Login: {0}: Invalid password for '{1}'", e.State, un);
|
logger.Information("Login: {NetState} Invalid password for '{Username}'", e.State, un);
|
||||||
e.RejectReason = ALRReason.BadPass;
|
e.RejectReason = ALRReason.BadPass;
|
||||||
}
|
}
|
||||||
else if (acct.Banned)
|
else if (acct.Banned)
|
||||||
{
|
{
|
||||||
logger.Information("Login: {0}: Banned account '{1}'", e.State, un);
|
logger.Information("Login: {NetState} Banned account '{Username}'", e.State, un);
|
||||||
e.RejectReason = ALRReason.Blocked;
|
e.RejectReason = ALRReason.Blocked;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Information("Login: {0}: Valid credentials for '{1}'", e.State, un);
|
logger.Information("Login: {NetState} Valid credentials for '{Username}'", e.State, un);
|
||||||
e.State.Account = acct;
|
e.State.Account = acct;
|
||||||
e.Accepted = true;
|
e.Accepted = true;
|
||||||
|
|
||||||
|
|
@ -405,7 +405,7 @@ namespace Server.Misc
|
||||||
{
|
{
|
||||||
e.Accepted = false;
|
e.Accepted = false;
|
||||||
|
|
||||||
logger.Warning("Login: {0}: Past IP limit threshold", e.State);
|
logger.Warning("Login: {NetState} Past IP limit threshold", e.State);
|
||||||
|
|
||||||
using var op = new StreamWriter("ipLimits.log", true);
|
using var op = new StreamWriter("ipLimits.log", true);
|
||||||
op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, Core.Now);
|
op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, Core.Now);
|
||||||
|
|
@ -422,24 +422,24 @@ namespace Server.Misc
|
||||||
}
|
}
|
||||||
else if (!acct.HasAccess(e.State))
|
else if (!acct.HasAccess(e.State))
|
||||||
{
|
{
|
||||||
logger.Information("Login: {0}: Access denied for '{1}'", e.State, un);
|
logger.Information("Login: {NetState} Access denied for '{Username}'", e.State, un);
|
||||||
e.Accepted = false;
|
e.Accepted = false;
|
||||||
}
|
}
|
||||||
else if (!acct.CheckPassword(pw))
|
else if (!acct.CheckPassword(pw))
|
||||||
{
|
{
|
||||||
logger.Information("Login: {0}: Invalid password for '{1}'", e.State, un);
|
logger.Information("Login: {NetState} Invalid password for '{Username}'", e.State, un);
|
||||||
e.Accepted = false;
|
e.Accepted = false;
|
||||||
}
|
}
|
||||||
else if (acct.Banned)
|
else if (acct.Banned)
|
||||||
{
|
{
|
||||||
logger.Information("Login: {0}: Banned account '{1}'", e.State, un);
|
logger.Information("Login: {NetState} Banned account '{Username}'", e.State, un);
|
||||||
e.Accepted = false;
|
e.Accepted = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
acct.LogAccess(e.State);
|
acct.LogAccess(e.State);
|
||||||
|
|
||||||
logger.Information("Login: {0}: Account '{1}' at character list", e.State, un);
|
logger.Information("Login: {NetState} Account '{Username}' at character list", e.State, un);
|
||||||
e.State.Account = acct;
|
e.State.Account = acct;
|
||||||
e.Accepted = true;
|
e.Accepted = true;
|
||||||
e.CityInfo = StartingCities;
|
e.CityInfo = StartingCities;
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ namespace Server.Engines.Chat
|
||||||
|
|
||||||
if (handler == null)
|
if (handler == null)
|
||||||
{
|
{
|
||||||
state.LogInfo("Unknown chat action 0x{0:X}: {1}", actionID, param);
|
state.LogInfo($"Unknown chat action 0x{actionID:X}: {param}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Server.Engines.MLQuests.Objectives
|
||||||
|
|
||||||
if (itemid is <= 0 or > 0x4000)
|
if (itemid is <= 0 or > 0x4000)
|
||||||
{
|
{
|
||||||
logger.Warning("Cliloc {0} is likely giving the wrong item ID", name.Number);
|
logger.Warning("Cliloc {Number} is likely giving the wrong item ID", name.Number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,13 +107,16 @@ namespace Server.Engines.Spawners
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
|
|
||||||
logger.Information("Generated {0} spawners ({1:F2} seconds, {2} failures)");
|
logger.Information(
|
||||||
from.SendMessage(
|
"Generated {Count} spawners ({Duration:F2} seconds, {Failures} failures)",
|
||||||
"GenerateSpawners: Generated {0} spawners ({1:F2} seconds, {2} failures)",
|
|
||||||
totalGenerated,
|
totalGenerated,
|
||||||
watch.Elapsed.TotalSeconds,
|
watch.Elapsed.TotalSeconds,
|
||||||
totalFailures
|
totalFailures
|
||||||
);
|
);
|
||||||
|
|
||||||
|
from.SendMessage(
|
||||||
|
$"GenerateSpawners: Generated {totalGenerated} spawners ({watch.Elapsed.TotalSeconds:F2} seconds, {totalFailures} failures)"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ParseSpawnerList(
|
private static void ParseSpawnerList(
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public static class AccountPrompt
|
||||||
AccessLevel = AccessLevel.Owner
|
AccessLevel = AccessLevel.Owner
|
||||||
};
|
};
|
||||||
|
|
||||||
logger.Information("Owner account created: {0}", username);
|
logger.Information("Owner account created: {Username}", username);
|
||||||
ServerAccess.AddProtectedAccount(a, true);
|
ServerAccess.AddProtectedAccount(a, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ namespace Server.Misc
|
||||||
|
|
||||||
if (newChar == null)
|
if (newChar == null)
|
||||||
{
|
{
|
||||||
logger.Information("Login: {0}: Character creation failed, account full", state);
|
logger.Information("Login: {NetState}: Character creation failed, account full", state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -122,14 +122,14 @@ namespace Server.Misc
|
||||||
if (boxes > 0)
|
if (boxes > 0)
|
||||||
{
|
{
|
||||||
logger.Information(
|
logger.Information(
|
||||||
"Cleanup: Detected {0} inaccessible items, including {1} bank boxes, removing..",
|
"Cleanup: Detected {Count} inaccessible items, including {BankBoxes} bank boxes, removing..",
|
||||||
items.Count,
|
items.Count,
|
||||||
boxes
|
boxes
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.Information("Cleanup: Detected {0} inaccessible items, removing..", items.Count);
|
logger.Information("Cleanup: Detected {Count} inaccessible items, removing..", items.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < items.Count; ++i)
|
for (var i = 0; i < items.Count; ++i)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ public static class ServerAccess
|
||||||
{
|
{
|
||||||
var username = acct.Username.ToLower();
|
var username = acct.Username.ToLower();
|
||||||
ServerAccessConfiguration.ProtectedAccounts.Add(username);
|
ServerAccessConfiguration.ProtectedAccounts.Add(username);
|
||||||
logger.Information("Protected account added: {0}", username);
|
logger.Information("Protected account added: {Username}", username);
|
||||||
|
|
||||||
if (save)
|
if (save)
|
||||||
{
|
{
|
||||||
|
|
@ -37,7 +37,7 @@ public static class ServerAccess
|
||||||
{
|
{
|
||||||
var username = acct.Username.ToLower();
|
var username = acct.Username.ToLower();
|
||||||
ServerAccessConfiguration.ProtectedAccounts.Remove(username);
|
ServerAccessConfiguration.ProtectedAccounts.Remove(username);
|
||||||
logger.Information("Protected account removed: {0}", username);
|
logger.Information("Protected account removed: {Username}", username);
|
||||||
|
|
||||||
if (save)
|
if (save)
|
||||||
{
|
{
|
||||||
|
|
@ -59,7 +59,7 @@ public static class ServerAccess
|
||||||
if (ServerAccessConfiguration.ProtectedAccounts.Count > 0)
|
if (ServerAccessConfiguration.ProtectedAccounts.Count > 0)
|
||||||
{
|
{
|
||||||
var protectedAccounts = string.Join(", ", ServerAccessConfiguration.ProtectedAccounts);
|
var protectedAccounts = string.Join(", ", ServerAccessConfiguration.ProtectedAccounts);
|
||||||
logger.Information("Protected accounts registered: {0}", protectedAccounts);
|
logger.Information("Protected accounts registered: {Count}", protectedAccounts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ public static class ServerAccess
|
||||||
acct.Banned = false;
|
acct.Banned = false;
|
||||||
acct.AccessLevel = AccessLevel.Owner;
|
acct.AccessLevel = AccessLevel.Owner;
|
||||||
|
|
||||||
logger.Warning("Protected account \"{0}\" has been reset.", username);
|
logger.Warning("Protected account \"{Username}\" has been reset.", username);
|
||||||
|
|
||||||
if (e.RejectReason is ALRReason.Blocked or ALRReason.BadPass or ALRReason.BadComm)
|
if (e.RejectReason is ALRReason.Blocked or ALRReason.BadPass or ALRReason.BadComm)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ namespace Server.Misc
|
||||||
|
|
||||||
if (_publicAddress != null)
|
if (_publicAddress != null)
|
||||||
{
|
{
|
||||||
logger.Information("Auto-detected public IP address ({0})", _publicAddress);
|
logger.Information("Auto-detected public IP address ({IPAddress})", _publicAddress);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -215,11 +215,11 @@ namespace Server.Multis
|
||||||
{
|
{
|
||||||
if (value.Count > 2)
|
if (value.Count > 2)
|
||||||
{
|
{
|
||||||
logger.Warning("More than 2 teleporters detected for {0:X}!", key);
|
logger.Warning("More than 2 teleporters detected for {ItemId:X}!", key);
|
||||||
}
|
}
|
||||||
else if (value.Count <= 1)
|
else if (value.Count <= 1)
|
||||||
{
|
{
|
||||||
logger.Warning("1 or less teleporters detected for {0:X}!", key);
|
logger.Warning("1 or less teleporters detected for {ItemId:X}!", key);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,7 @@ namespace Server.Multis
|
||||||
|
|
||||||
if (ce != ZlibError.Okay)
|
if (ce != ZlibError.Okay)
|
||||||
{
|
{
|
||||||
logger.Warning("ZLib error: {0} (#{1})", ce, (int)ce);
|
logger.Warning("ZLib error: {Error} (#{ErrorCode})", ce, (int)ce);
|
||||||
length = 0;
|
length = 0;
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Server.Network
|
||||||
|
|
||||||
if (ph.Ingame && state.Mobile == null)
|
if (ph.Ingame && state.Mobile == null)
|
||||||
{
|
{
|
||||||
state.LogInfo("Sent in-game packet (0x{0:X2}x{1:X2}) before having been attached to a mobile", packetId, cmd);
|
state.LogInfo($"Sent in-game packet (0x{packetId:X2}x{cmd:X2}) before having been attached to a mobile");
|
||||||
state.Disconnect("Sent in-game packet before being attached to a mobile.");
|
state.Disconnect("Sent in-game packet before being attached to a mobile.");
|
||||||
}
|
}
|
||||||
else if (ph.Ingame && state.Mobile.Deleted)
|
else if (ph.Ingame && state.Mobile.Deleted)
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Server.Regions
|
||||||
|
|
||||||
if (!typeof(BaseGuard).IsAssignableFrom(m_GuardType))
|
if (!typeof(BaseGuard).IsAssignableFrom(m_GuardType))
|
||||||
{
|
{
|
||||||
logger.Warning("Invalid guard type for region '{0}'", this);
|
logger.Warning("Invalid guard type for region '{Region}'", this);
|
||||||
m_GuardType = DefaultGuardType;
|
m_GuardType = DefaultGuardType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue