Make logger a non-static class

This commit is contained in:
jvyden 2022-05-15 16:57:50 -04:00
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

@ -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);

View file

@ -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();
}