chore(logging): Migrate some logs to ILogger (#582)
This commit is contained in:
parent
421d852991
commit
c6cbda6f52
16 changed files with 103 additions and 76 deletions
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using Server.Accounting;
|
||||
using Server.Factions;
|
||||
using Server.Items;
|
||||
using Server.Logging;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
|
|
@ -9,6 +10,8 @@ namespace Server.Misc
|
|||
{
|
||||
public static class CharacterCreation
|
||||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(CharacterCreation));
|
||||
|
||||
private static readonly TimeSpan BadStartMessageDelay = TimeSpan.FromSeconds(3.5);
|
||||
|
||||
private static readonly CityInfo m_NewHavenInfo =
|
||||
|
|
@ -630,7 +633,7 @@ namespace Server.Misc
|
|||
|
||||
if (newChar == null)
|
||||
{
|
||||
Console.WriteLine("Login: {0}: Character creation failed, account full", state);
|
||||
logger.Information("Login: {0}: Character creation failed, account full", state);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -700,9 +703,15 @@ namespace Server.Misc
|
|||
|
||||
newChar.MoveToWorld(city.Location, city.Map);
|
||||
|
||||
Console.WriteLine("Login: {0}: New character being created (account={1})", state, args.Account.Username);
|
||||
Console.WriteLine(" - Character: {0} (serial={1})", newChar.Name, newChar.Serial);
|
||||
Console.WriteLine(" - Started: {0} {1} in {2}", city.City, city.Location, city.Map);
|
||||
logger.Information(
|
||||
"Login: {0}: New character being created (account={1}, character={2}, serial={3}, started.city={4}, started.location={5}, started.map={6})",
|
||||
state,
|
||||
args.Account.Username,
|
||||
newChar.Name,
|
||||
newChar.Serial,
|
||||
city.City,
|
||||
city.Location,
|
||||
city.Map);
|
||||
|
||||
new WelcomeTimer(newChar).Start();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Items;
|
||||
using Server.Logging;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public static class Cleanup
|
||||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(Cleanup));
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
Timer.DelayCall(TimeSpan.FromSeconds(2.5), Run);
|
||||
|
|
@ -118,7 +121,7 @@ namespace Server.Misc
|
|||
{
|
||||
if (boxes > 0)
|
||||
{
|
||||
Console.WriteLine(
|
||||
logger.Information(
|
||||
"Cleanup: Detected {0} inaccessible items, including {1} bank boxes, removing..",
|
||||
items.Count,
|
||||
boxes
|
||||
|
|
@ -126,7 +129,7 @@ namespace Server.Misc
|
|||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Cleanup: Detected {0} inaccessible items, removing..", items.Count);
|
||||
logger.Information("Cleanup: Detected {0} inaccessible items, removing..", items.Count);
|
||||
}
|
||||
|
||||
for (var i = 0; i < items.Count; ++i)
|
||||
|
|
@ -137,7 +140,7 @@ namespace Server.Misc
|
|||
|
||||
if (hairCleanup.Count > 0)
|
||||
{
|
||||
Console.WriteLine(
|
||||
logger.Information(
|
||||
"Cleanup: Detected {0} hair and facial hair items being worn, converting to their virtual counterparts..",
|
||||
hairCleanup.Count
|
||||
);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Server.Gumps;
|
||||
using Server.Logging;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
|
|
@ -9,6 +10,8 @@ namespace Server.Misc
|
|||
{
|
||||
public static class ClientVerification
|
||||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(ClientVerification));
|
||||
|
||||
private static bool m_DetectClientRequirement;
|
||||
private static OldClientResponse m_OldClientResponse;
|
||||
|
||||
|
|
@ -65,13 +68,11 @@ namespace Server.Misc
|
|||
|
||||
if (Required != null)
|
||||
{
|
||||
Utility.PushColor(ConsoleColor.White);
|
||||
Console.WriteLine(
|
||||
logger.Information(
|
||||
"Restricting client version to {0}. Action to be taken: {1}",
|
||||
Required,
|
||||
m_OldClientResponse
|
||||
);
|
||||
Utility.PopColor();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,12 +2,15 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Server.Accounting;
|
||||
using Server.Logging;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public static class CrashGuard
|
||||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(CrashGuard));
|
||||
|
||||
private static bool Enabled;
|
||||
private static bool SaveBackup;
|
||||
private static bool RestartServer; // Disable this if using a daemon/service
|
||||
|
|
@ -51,25 +54,25 @@ namespace Server.Misc
|
|||
|
||||
private static void SendEmail(string filePath)
|
||||
{
|
||||
Console.Write("Crash: Sending email...");
|
||||
logger.Information("Sending crash email");
|
||||
|
||||
Email.SendCrashEmail(filePath);
|
||||
}
|
||||
|
||||
private static void Restart(ServerCrashedEventArgs e)
|
||||
{
|
||||
Console.Write("Crash: Restarting...");
|
||||
logger.Information("Restarting");
|
||||
|
||||
try
|
||||
{
|
||||
Process.Start(Core.Assembly.Location, Core.Arguments);
|
||||
Console.WriteLine("done");
|
||||
logger.Information("Restart done");
|
||||
|
||||
e.Close = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("failed");
|
||||
logger.Error("Restart failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +99,7 @@ namespace Server.Misc
|
|||
|
||||
private static void Backup()
|
||||
{
|
||||
Console.Write("Crash: Backing up...");
|
||||
logger.Information("Backing up");
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -123,17 +126,17 @@ namespace Server.Misc
|
|||
CopyFile(rootOrigin, rootBackup, "Regions/Regions.bin");
|
||||
CopyFile(rootOrigin, rootBackup, "Regions/Regions.idx");
|
||||
|
||||
Console.WriteLine("done");
|
||||
logger.Information("Backup done");
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("failed");
|
||||
logger.Error("Backup failed");
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateCrashReport(ServerCrashedEventArgs e)
|
||||
{
|
||||
Console.Write("Crash: Generating report...");
|
||||
logger.Information("Generating crash report");
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -210,13 +213,13 @@ namespace Server.Misc
|
|||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("done");
|
||||
logger.Information("Crash report generated");
|
||||
|
||||
SendEmail(filePath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("failed");
|
||||
logger.Error("Crash report generation failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,14 @@ using System.Linq;
|
|||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using Server.Logging;
|
||||
|
||||
namespace Server.Misc
|
||||
{
|
||||
public static class ServerList
|
||||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(ServerList));
|
||||
|
||||
private static IPAddress m_PublicAddress;
|
||||
/*
|
||||
* The default setting for Address, a value of 'null', will use your local IP address. If all of your local IP addresses
|
||||
|
|
@ -91,7 +94,7 @@ namespace Server.Misc
|
|||
}
|
||||
catch (Exception er)
|
||||
{
|
||||
Console.WriteLine(er);
|
||||
logger.Warning(er, "Unhandled exception at server list");
|
||||
e.Rejected = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -100,16 +103,15 @@ namespace Server.Misc
|
|||
{
|
||||
if (!HasPublicIPAddress())
|
||||
{
|
||||
Console.Write("ServerList: Auto-detecting public IP address...");
|
||||
m_PublicAddress = FindPublicAddress();
|
||||
|
||||
if (m_PublicAddress != null)
|
||||
{
|
||||
Console.WriteLine("done ({0})", m_PublicAddress);
|
||||
logger.Information("Auto-detected public IP address ({0})", m_PublicAddress);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("failed");
|
||||
logger.Warning("Could not auto-detect public IP address");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue