mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-30 00:38:38 +00:00
Replace all Console.WriteLine instances with Logger.Log
This commit is contained in:
parent
fe03663f38
commit
847ba3da0c
4 changed files with 17 additions and 4 deletions
|
@ -11,6 +11,11 @@ namespace LBPUnion.ProjectLighthouse.Logging {
|
||||||
public static LoggerLevelDatabase Instance = new();
|
public static LoggerLevelDatabase Instance = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class LoggerLevelHttp : LoggerLevel {
|
||||||
|
public override string Name => "HTTP";
|
||||||
|
public static LoggerLevelDatabase Instance = new();
|
||||||
|
}
|
||||||
|
|
||||||
#region ASP.NET
|
#region ASP.NET
|
||||||
public class LoggerLevelAspNetTrace : LoggerLevel {
|
public class LoggerLevelAspNetTrace : LoggerLevel {
|
||||||
public override string Name => "ASP.NET: Trace";
|
public override string Name => "ASP.NET: Trace";
|
||||||
|
|
|
@ -9,7 +9,6 @@ using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Logging.Console;
|
|
||||||
|
|
||||||
namespace LBPUnion.ProjectLighthouse {
|
namespace LBPUnion.ProjectLighthouse {
|
||||||
public static class Program {
|
public static class Program {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using Kettu;
|
||||||
|
using LBPUnion.ProjectLighthouse.Logging;
|
||||||
using LBPUnion.ProjectLighthouse.Serialization;
|
using LBPUnion.ProjectLighthouse.Serialization;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
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
|
await next(); // Handle the request so we can get the status code from it
|
||||||
|
|
||||||
requestStopwatch.Stop();
|
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") {
|
if(context.Request.Method == "POST") {
|
||||||
context.Request.Body.Position = 0;
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
|
using Kettu;
|
||||||
|
using LBPUnion.ProjectLighthouse.Logging;
|
||||||
|
|
||||||
namespace LBPUnion.ProjectLighthouse.Types.Settings {
|
namespace LBPUnion.ProjectLighthouse.Types.Settings {
|
||||||
public static class ServerSettings {
|
public static class ServerSettings {
|
||||||
|
@ -29,7 +31,7 @@ namespace LBPUnion.ProjectLighthouse.Types.Settings {
|
||||||
return new Database().Database.CanConnect();
|
return new Database().Database.CanConnect();
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
Console.WriteLine(e);
|
Logger.Log(e.ToString(), LoggerLevelDatabase.Instance);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue