Make logger a non-static class

This commit is contained in:
jvyden 2022-05-15 16:57:50 -04:00
parent c345eeebb9
commit 630b38e7bb
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
27 changed files with 167 additions and 141 deletions

View file

@ -44,14 +44,14 @@ public class LoginController : ControllerBase
if (npTicket == null)
{
Logger.LogWarn("npTicket was null, rejecting login", LogArea.Login);
Logger.Warn("npTicket was null, rejecting login", LogArea.Login);
return this.BadRequest();
}
IPAddress? remoteIpAddress = this.HttpContext.Connection.RemoteIpAddress;
if (remoteIpAddress == null)
{
Logger.LogWarn("unable to determine ip, rejecting login", LogArea.Login);
Logger.Warn("unable to determine ip, rejecting login", LogArea.Login);
return this.StatusCode(403, ""); // 403 probably isnt the best status code for this, but whatever
}
@ -67,7 +67,7 @@ public class LoginController : ControllerBase
token = await this.database.AuthenticateUser(npTicket, ipAddress);
if (token == null)
{
Logger.LogWarn($"Unable to find/generate a token for username {npTicket.Username}", LogArea.Login);
Logger.Warn($"Unable to find/generate a token for username {npTicket.Username}", LogArea.Login);
return this.StatusCode(403, ""); // If not, then 403.
}
}
@ -76,7 +76,7 @@ public class LoginController : ControllerBase
if (user == null || user.Banned)
{
Logger.LogError($"Unable to find user {npTicket.Username} from token", LogArea.Login);
Logger.Error($"Unable to find user {npTicket.Username} from token", LogArea.Login);
return this.StatusCode(403, "");
}
@ -109,11 +109,11 @@ public class LoginController : ControllerBase
if (!token.Approved)
{
Logger.LogWarn($"Token unapproved for user {user.Username}, rejecting login", LogArea.Login);
Logger.Warn($"Token unapproved for user {user.Username}, rejecting login", LogArea.Login);
return this.StatusCode(403, "");
}
Logger.LogSuccess($"Successfully logged in user {user.Username} as {token.GameVersion} client", LogArea.Login);
Logger.Success($"Successfully logged in user {user.Username} as {token.GameVersion} client", LogArea.Login);
// After this point we are now considering this session as logged in.
// We just logged in with the token. Mark it as used so someone else doesnt try to use it,