mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-28 16:08:38 +00:00
Make logger a non-static class
This commit is contained in:
parent
c345eeebb9
commit
630b38e7bb
27 changed files with 167 additions and 141 deletions
|
@ -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,
|
||||
|
|
|
@ -46,7 +46,7 @@ public class MatchController : ControllerBase
|
|||
|
||||
if (bodyString.Length == 0 || bodyString[0] != '[') return this.BadRequest();
|
||||
|
||||
Logger.LogInfo("Received match data: " + bodyString, LogArea.Match);
|
||||
Logger.Info("Received match data: " + bodyString, LogArea.Match);
|
||||
|
||||
IMatchCommand? matchData;
|
||||
try
|
||||
|
@ -55,19 +55,19 @@ public class MatchController : ControllerBase
|
|||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Logger.LogError("Exception while parsing matchData: ", LogArea.Match);
|
||||
Logger.LogError(e.ToDetailedException(), LogArea.Match);
|
||||
Logger.Error("Exception while parsing matchData: ", LogArea.Match);
|
||||
Logger.Error(e.ToDetailedException(), LogArea.Match);
|
||||
|
||||
return this.BadRequest();
|
||||
}
|
||||
|
||||
if (matchData == null)
|
||||
{
|
||||
Logger.LogError($"Could not parse match data: {nameof(matchData)} is null", LogArea.Match);
|
||||
Logger.Error($"Could not parse match data: {nameof(matchData)} is null", LogArea.Match);
|
||||
return this.BadRequest();
|
||||
}
|
||||
|
||||
Logger.LogInfo($"Parsed match from {user.Username} (type: {matchData.GetType()})", LogArea.Match);
|
||||
Logger.Info($"Parsed match from {user.Username} (type: {matchData.GetType()})", LogArea.Match);
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.";
|
|||
|
||||
string scannedText = CensorHelper.ScanMessage(response);
|
||||
|
||||
Logger.LogInfo($"{user.Username}: {response} / {scannedText}", LogArea.Filter);
|
||||
Logger.Info($"{user.Username}: {response} / {scannedText}", LogArea.Filter);
|
||||
|
||||
return this.Ok(scannedText);
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ public class PhotosController : ControllerBase
|
|||
if (subject.User == null) continue;
|
||||
|
||||
subject.UserId = subject.User.UserId;
|
||||
Logger.LogDebug($"Adding PhotoSubject (userid {subject.UserId}) to db", LogArea.Photos);
|
||||
Logger.Debug($"Adding PhotoSubject (userid {subject.UserId}) to db", LogArea.Photos);
|
||||
|
||||
this.database.PhotoSubjects.Add(subject);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class PhotosController : ControllerBase
|
|||
|
||||
// photo.Slot = await this.database.Slots.FirstOrDefaultAsync(s => s.SlotId == photo.SlotId);
|
||||
|
||||
Logger.LogDebug($"Adding PhotoSubjectCollection ({photo.PhotoSubjectCollection}) to photo", LogArea.Photos);
|
||||
Logger.Debug($"Adding PhotoSubjectCollection ({photo.PhotoSubjectCollection}) to photo", LogArea.Photos);
|
||||
|
||||
this.database.Photos.Add(photo);
|
||||
|
||||
|
|
|
@ -77,24 +77,24 @@ public class ResourcesController : ControllerBase
|
|||
// lbp treats code 409 as success and as an indicator that the file is already present
|
||||
if (FileHelper.ResourceExists(hash)) this.Conflict();
|
||||
|
||||
Logger.LogInfo($"Processing resource upload (hash: {hash})", LogArea.Resources);
|
||||
Logger.Info($"Processing resource upload (hash: {hash})", LogArea.Resources);
|
||||
LbpFile file = new(await readFromPipeReader(this.Request.BodyReader));
|
||||
|
||||
if (!FileHelper.IsFileSafe(file))
|
||||
{
|
||||
Logger.LogWarn($"File is unsafe (hash: {hash}, type: {file.FileType})", LogArea.Resources);
|
||||
Logger.Warn($"File is unsafe (hash: {hash}, type: {file.FileType})", LogArea.Resources);
|
||||
return this.Conflict();
|
||||
}
|
||||
|
||||
string calculatedHash = file.Hash;
|
||||
if (calculatedHash != hash)
|
||||
{
|
||||
Logger.LogWarn
|
||||
Logger.Warn
|
||||
($"File hash does not match the uploaded file! (hash: {hash}, calculatedHash: {calculatedHash}, type: {file.FileType})", LogArea.Resources);
|
||||
return this.Conflict();
|
||||
}
|
||||
|
||||
Logger.LogSuccess($"File is OK! (hash: {hash}, type: {file.FileType})", LogArea.Resources);
|
||||
Logger.Success($"File is OK! (hash: {hash}, type: {file.FileType})", LogArea.Resources);
|
||||
await IOFile.WriteAllBytesAsync(path, file.Data);
|
||||
return this.Ok();
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public class CollectionController : ControllerBase
|
|||
Category? category = CategoryHelper.Categories.FirstOrDefault(c => c.Endpoint == endpointName);
|
||||
if (category == null) return this.NotFound();
|
||||
|
||||
Logger.LogDebug("Found category " + category, LogArea.Category);
|
||||
Logger.Debug("Found category " + category, LogArea.Category);
|
||||
|
||||
List<Slot> slots;
|
||||
int totalSlots;
|
||||
|
|
|
@ -51,7 +51,7 @@ public class GameServerStartup
|
|||
|
||||
if (string.IsNullOrEmpty(ServerConfiguration.Instance.DigestKey.PrimaryDigestKey))
|
||||
{
|
||||
Logger.LogWarn
|
||||
Logger.Warn
|
||||
(
|
||||
"The serverDigestKey configuration option wasn't set, so digest headers won't be set or verified. This will also prevent LBP 1, LBP 2, and LBP Vita from working. " +
|
||||
"To increase security, it is recommended that you find and set this variable.",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue