diff --git a/ProjectLighthouse/Logging/LoggerLevels.cs b/ProjectLighthouse/Logging/LoggerLevels.cs index 5bb26a93..7574da39 100644 --- a/ProjectLighthouse/Logging/LoggerLevels.cs +++ b/ProjectLighthouse/Logging/LoggerLevels.cs @@ -11,6 +11,11 @@ namespace LBPUnion.ProjectLighthouse.Logging { public static LoggerLevelDatabase Instance = new(); } + public class LoggerLevelHttp : LoggerLevel { + public override string Name => "HTTP"; + public static LoggerLevelDatabase Instance = new(); + } + #region ASP.NET public class LoggerLevelAspNetTrace : LoggerLevel { public override string Name => "ASP.NET: Trace"; diff --git a/ProjectLighthouse/Program.cs b/ProjectLighthouse/Program.cs index 70b8708f..8b2a6bf2 100644 --- a/ProjectLighthouse/Program.cs +++ b/ProjectLighthouse/Program.cs @@ -9,7 +9,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Console; namespace LBPUnion.ProjectLighthouse { public static class Program { diff --git a/ProjectLighthouse/Startup.cs b/ProjectLighthouse/Startup.cs index f902da5c..5ef7cd7c 100644 --- a/ProjectLighthouse/Startup.cs +++ b/ProjectLighthouse/Startup.cs @@ -1,6 +1,8 @@ using System; using System.Diagnostics; using System.IO; +using Kettu; +using LBPUnion.ProjectLighthouse.Logging; using LBPUnion.ProjectLighthouse.Serialization; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -43,10 +45,15 @@ namespace LBPUnion.ProjectLighthouse { await next(); // Handle the request so we can get the status code from it requestStopwatch.Stop(); - Console.WriteLine($"{context.Response.StatusCode}, {requestStopwatch.ElapsedMilliseconds}ms: {context.Request.Method} {context.Request.Path}{context.Request.QueryString}"); + + Logger.Log( + $"{context.Response.StatusCode}, {requestStopwatch.ElapsedMilliseconds}ms: {context.Request.Method} {context.Request.Path}{context.Request.QueryString}", + LoggerLevelHttp.Instance + ); + if(context.Request.Method == "POST") { context.Request.Body.Position = 0; - Console.WriteLine(await new StreamReader(context.Request.Body).ReadToEndAsync()); + Logger.Log(await new StreamReader(context.Request.Body).ReadToEndAsync(), LoggerLevelHttp.Instance); } }); diff --git a/ProjectLighthouse/Types/Settings/ServerSettings.cs b/ProjectLighthouse/Types/Settings/ServerSettings.cs index 01031eef..1e456c23 100644 --- a/ProjectLighthouse/Types/Settings/ServerSettings.cs +++ b/ProjectLighthouse/Types/Settings/ServerSettings.cs @@ -1,5 +1,7 @@ #nullable enable using System; +using Kettu; +using LBPUnion.ProjectLighthouse.Logging; namespace LBPUnion.ProjectLighthouse.Types.Settings { public static class ServerSettings { @@ -29,7 +31,7 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings { return new Database().Database.CanConnect(); } catch(Exception e) { - Console.WriteLine(e); + Logger.Log(e.ToString(), LoggerLevelDatabase.Instance); return false; } }