mirror of
https://git.lewd.wtf/PGR/ascnet
synced 2025-12-13 07:14:34 +01:00
add proper logger, saves to file as well
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AscNet.Common\AscNet.Common.csproj" />
|
||||
<ProjectReference Include="..\AscNet.Logging\AscNet.Logging.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace AscNet.SDKServer.Controllers
|
||||
remoteConfigs.AddConfig("PcPayCallbackList", $"{Common.Common.config.GameServer.Host}/api/XPay/KuroPayResult");
|
||||
|
||||
string serializedObject = TsvTool.SerializeObject(remoteConfigs);
|
||||
SDKServer.c.Log(serializedObject);
|
||||
SDKServer.log.Info(serializedObject);
|
||||
return serializedObject;
|
||||
});
|
||||
|
||||
@@ -61,13 +61,13 @@ namespace AscNet.SDKServer.Controllers
|
||||
Title = "NOTICE"
|
||||
};
|
||||
string serializedObject = JsonConvert.SerializeObject(notice);
|
||||
SDKServer.c.Log(serializedObject);
|
||||
SDKServer.log.Info(serializedObject);
|
||||
return serializedObject;
|
||||
});
|
||||
|
||||
app.MapPost("/feedback", (HttpContext ctx) =>
|
||||
{
|
||||
SDKServer.c.Log("1");
|
||||
SDKServer.log.Info("1");
|
||||
return "1";
|
||||
});
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace AscNet.SDKServer.Controllers
|
||||
Token = token
|
||||
};
|
||||
string serializedObject = JsonConvert.SerializeObject(gate);
|
||||
SDKServer.c.Log(serializedObject);
|
||||
SDKServer.log.Info(serializedObject);
|
||||
return serializedObject;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using AscNet.Logging;
|
||||
|
||||
namespace AscNet.SDKServer
|
||||
{
|
||||
public class SDKServer
|
||||
{
|
||||
public static readonly Common.Util.Logger c = new(nameof(SDKServer), ConsoleColor.Green);
|
||||
public static readonly Logger log = new(typeof(SDKServer), Logging.LogLevel.DEBUG, Logging.LogLevel.DEBUG);
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
@@ -25,14 +27,14 @@ namespace AscNet.SDKServer
|
||||
{
|
||||
controller.GetMethod(nameof(IRegisterable.Register))!.Invoke(null, new object[] { app });
|
||||
#if DEBUG
|
||||
c.Log($"Registered HTTP controller '{controller.Name}'");
|
||||
log.Info($"Registered HTTP controller '{controller.Name}'");
|
||||
#endif
|
||||
}
|
||||
|
||||
app.UseMiddleware<RequestLoggingMiddleware>();
|
||||
|
||||
new Thread(() => app.Run()).Start();
|
||||
c.Log($"{nameof(SDKServer)} started in port {string.Join(", ", app.Urls.Select(x => x.Split(':').Last()))}!");
|
||||
log.Info($"{nameof(SDKServer)} started in port {string.Join(", ", app.Urls.Select(x => x.Split(':').Last()))}!");
|
||||
}
|
||||
|
||||
private class RequestLoggingMiddleware
|
||||
@@ -53,7 +55,7 @@ namespace AscNet.SDKServer
|
||||
}
|
||||
finally
|
||||
{
|
||||
c.Log($"{context.Response.StatusCode} {context.Request.Method.ToUpper()} {context.Request.Path + context.Request.QueryString}");
|
||||
log.Info($"{context.Response.StatusCode} {context.Request.Method.ToUpper()} {context.Request.Path + context.Request.QueryString}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user