mirror of
https://github.com/MikuLeaks/KianaBH3.git
synced 2026-03-24 23:32:25 +01:00
Init enter game
This commit is contained in:
34
Common/Util/LoggingMiddleware.cs
Normal file
34
Common/Util/LoggingMiddleware.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using KianaBH.Util;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace KianaBH.SdkServer.Utils;
|
||||
|
||||
public class RequestLoggingMiddleware(RequestDelegate next)
|
||||
{
|
||||
public async Task InvokeAsync(HttpContext context, Logger logger)
|
||||
{
|
||||
var request = context.Request;
|
||||
var method = request.Method;
|
||||
var path = request.Path + request.QueryString;
|
||||
|
||||
await next(context);
|
||||
|
||||
var statusCode = context.Response.StatusCode;
|
||||
|
||||
if (path.StartsWith("/report") || path.Contains("/log/") || path == "/alive")
|
||||
return;
|
||||
|
||||
if (statusCode == 200)
|
||||
{
|
||||
logger.Info($"{method} {path} => {statusCode}");
|
||||
}
|
||||
else if (statusCode == 404)
|
||||
{
|
||||
logger.Warn($"{method} {path} => {statusCode}");
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Error($"{method} {path} => {statusCode}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user