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
|
|
@ -4,6 +4,8 @@ using System.IO;
|
|||
using System.Net;
|
||||
using Server.Accounting;
|
||||
using Server.Engines.Help;
|
||||
using Server.Logging;
|
||||
using Server.Multis;
|
||||
using Server.Network;
|
||||
using Server.Regions;
|
||||
|
||||
|
|
@ -11,6 +13,8 @@ namespace Server.Misc
|
|||
{
|
||||
public static class AccountHandler
|
||||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(AccountHandler));
|
||||
|
||||
private static int MaxAccountsPerIP;
|
||||
private static bool AutoAccountCreation;
|
||||
private static readonly bool RestrictDeletion = !TestCenter.Enabled;
|
||||
|
|
@ -309,7 +313,7 @@ namespace Server.Misc
|
|||
|
||||
if (!CanCreate(state.Address))
|
||||
{
|
||||
Console.WriteLine(
|
||||
logger.Information(
|
||||
"Login: {0}: Account '{1}' not created, ip already has {2} account{3}.",
|
||||
state,
|
||||
un,
|
||||
|
|
@ -319,7 +323,7 @@ namespace Server.Misc
|
|||
return null;
|
||||
}
|
||||
|
||||
Console.WriteLine("Login: {0}: Creating new account '{1}'", state, un);
|
||||
logger.Information("Login: {0}: Creating new account '{1}'", state, un);
|
||||
|
||||
var a = new Account(un, pw);
|
||||
|
||||
|
|
@ -333,7 +337,7 @@ namespace Server.Misc
|
|||
e.Accepted = false;
|
||||
e.RejectReason = ALRReason.InUse;
|
||||
|
||||
Console.WriteLine("Login: {0}: Past IP limit threshold", e.State);
|
||||
logger.Information("Login: {0}: Past IP limit threshold", e.State);
|
||||
|
||||
using var op = new StreamWriter("ipLimits.log", true);
|
||||
op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, Core.Now);
|
||||
|
|
@ -361,28 +365,28 @@ namespace Server.Misc
|
|||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Login: {0}: Invalid username '{1}'", e.State, un);
|
||||
logger.Information("Login: {0}: Invalid username '{1}'", e.State, un);
|
||||
e.RejectReason = ALRReason.Invalid;
|
||||
}
|
||||
}
|
||||
else if (!acct.HasAccess(e.State))
|
||||
{
|
||||
Console.WriteLine("Login: {0}: Access denied for '{1}'", e.State, un);
|
||||
logger.Information("Login: {0}: Access denied for '{1}'", e.State, un);
|
||||
e.RejectReason = LockdownLevel > AccessLevel.Player ? ALRReason.BadComm : ALRReason.BadPass;
|
||||
}
|
||||
else if (!acct.CheckPassword(pw))
|
||||
{
|
||||
Console.WriteLine("Login: {0}: Invalid password for '{1}'", e.State, un);
|
||||
logger.Information("Login: {0}: Invalid password for '{1}'", e.State, un);
|
||||
e.RejectReason = ALRReason.BadPass;
|
||||
}
|
||||
else if (acct.Banned)
|
||||
{
|
||||
Console.WriteLine("Login: {0}: Banned account '{1}'", e.State, un);
|
||||
logger.Information("Login: {0}: Banned account '{1}'", e.State, un);
|
||||
e.RejectReason = ALRReason.Blocked;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Login: {0}: Valid credentials for '{1}'", e.State, un);
|
||||
logger.Information("Login: {0}: Valid credentials for '{1}'", e.State, un);
|
||||
e.State.Account = acct;
|
||||
e.Accepted = true;
|
||||
|
||||
|
|
@ -401,7 +405,7 @@ namespace Server.Misc
|
|||
{
|
||||
e.Accepted = false;
|
||||
|
||||
Console.WriteLine("Login: {0}: Past IP limit threshold", e.State);
|
||||
logger.Warning("Login: {0}: Past IP limit threshold", e.State);
|
||||
|
||||
using var op = new StreamWriter("ipLimits.log", true);
|
||||
op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, Core.Now);
|
||||
|
|
@ -418,24 +422,24 @@ namespace Server.Misc
|
|||
}
|
||||
else if (!acct.HasAccess(e.State))
|
||||
{
|
||||
Console.WriteLine("Login: {0}: Access denied for '{1}'", e.State, un);
|
||||
logger.Information("Login: {0}: Access denied for '{1}'", e.State, un);
|
||||
e.Accepted = false;
|
||||
}
|
||||
else if (!acct.CheckPassword(pw))
|
||||
{
|
||||
Console.WriteLine("Login: {0}: Invalid password for '{1}'", e.State, un);
|
||||
logger.Information("Login: {0}: Invalid password for '{1}'", e.State, un);
|
||||
e.Accepted = false;
|
||||
}
|
||||
else if (acct.Banned)
|
||||
{
|
||||
Console.WriteLine("Login: {0}: Banned account '{1}'", e.State, un);
|
||||
logger.Information("Login: {0}: Banned account '{1}'", e.State, un);
|
||||
e.Accepted = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
acct.LogAccess(e.State);
|
||||
|
||||
Console.WriteLine("Login: {0}: Account '{1}' at character list", e.State, un);
|
||||
logger.Information("Login: {0}: Account '{1}' at character list", e.State, un);
|
||||
e.State.Account = acct;
|
||||
e.Accepted = true;
|
||||
e.CityInfo = StartingCities;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue