Add writing headClerk2 request info to csv log files
This commit is contained in:
parent
614b693760
commit
d179ff4a4e
@ -4,16 +4,36 @@
|
|||||||
[Route("/v12r00_cn/chassis/headclerk2.php")]
|
[Route("/v12r00_cn/chassis/headclerk2.php")]
|
||||||
public class Headclerk2Controller : BaseController<Headclerk2Controller>
|
public class Headclerk2Controller : BaseController<Headclerk2Controller>
|
||||||
{
|
{
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/protobuf")]
|
[Produces("application/protobuf")]
|
||||||
public IActionResult Headclerk2([FromBody] HeadClerk2Request request)
|
public IActionResult Headclerk2([FromBody] HeadClerk2Request request)
|
||||||
{
|
{
|
||||||
Logger.LogInformation("Headclerk2 request: {Request}", request.Stringify());
|
Logger.LogInformation("Headclerk2 request: {Request}", request.Stringify());
|
||||||
var response = new HeadClerk2Response
|
|
||||||
{
|
|
||||||
Result = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
return Ok(response);
|
var chassisId = request.ChassisId;
|
||||||
}
|
var shopId = request.ShopId;
|
||||||
|
foreach (var playInfo in request.AryPlayInfoes)
|
||||||
|
{
|
||||||
|
var baid = playInfo.Baid;
|
||||||
|
var playedAt = playInfo.PlayedAt;
|
||||||
|
var isRight = playInfo.IsRight;
|
||||||
|
var type = playInfo.Type;
|
||||||
|
var amount = playInfo.Amount;
|
||||||
|
Logger.LogInformation("CSV WRITE: \n" +
|
||||||
|
"ChassisId:{ChassisId},\n" +
|
||||||
|
"ShopId:{ShopId},\n" +
|
||||||
|
"Baid:{Baid},\n" +
|
||||||
|
"PlayedAt{PlayedAt},\n" +
|
||||||
|
"IsRight:{IsRight},\n" +
|
||||||
|
"Type:{Type},\n" +
|
||||||
|
"Amount{Amount}", chassisId, shopId, baid, playedAt, isRight, type, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = new HeadClerk2Response
|
||||||
|
{
|
||||||
|
Result = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
return Ok(response);
|
||||||
|
}
|
||||||
}
|
}
|
20
TaikoLocalServer/Controllers/Game/SetAnyStringController.cs
Normal file
20
TaikoLocalServer/Controllers/Game/SetAnyStringController.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
namespace TaikoLocalServer.Controllers.Game;
|
||||||
|
|
||||||
|
[Route("/v12r00_cn/chassis/setanystring.php")]
|
||||||
|
[ApiController]
|
||||||
|
public class SetAnyStringController : BaseController<SetAnyStringController>
|
||||||
|
{
|
||||||
|
[HttpPost]
|
||||||
|
[Produces("application/protobuf")]
|
||||||
|
public IActionResult SetAnyString([FromBody] SetAnyStringRequest request)
|
||||||
|
{
|
||||||
|
Logger.LogInformation("SetAnyString request : {Request}", request.Stringify());
|
||||||
|
|
||||||
|
var response = new SetAnyStringResponse
|
||||||
|
{
|
||||||
|
Result = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Ok(response);
|
||||||
|
}
|
||||||
|
}
|
35
TaikoLocalServer/Logging/CsvFormatter.cs
Normal file
35
TaikoLocalServer/Logging/CsvFormatter.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using Serilog.Events;
|
||||||
|
using Serilog.Formatting;
|
||||||
|
|
||||||
|
namespace TaikoLocalServer.Logging;
|
||||||
|
|
||||||
|
public class CsvFormatter: ITextFormatter
|
||||||
|
{
|
||||||
|
public void Format(LogEvent logEvent, TextWriter output)
|
||||||
|
{
|
||||||
|
logEvent.Properties.TryGetValue("ChassisId", out var chassisId);
|
||||||
|
logEvent.Properties.TryGetValue("ShopId", out var shopId);
|
||||||
|
logEvent.Properties.TryGetValue("Baid", out var baid);
|
||||||
|
logEvent.Properties.TryGetValue("PlayedAt", out var playedAt);
|
||||||
|
logEvent.Properties.TryGetValue("IsRight", out var isRight);
|
||||||
|
logEvent.Properties.TryGetValue("Type", out var type);
|
||||||
|
logEvent.Properties.TryGetValue("Amount", out var amount);
|
||||||
|
|
||||||
|
output.Write(logEvent.Timestamp.ToString("yyyy-MM-dd"));
|
||||||
|
output.Write(",");
|
||||||
|
output.Write(chassisId);
|
||||||
|
output.Write(",");
|
||||||
|
output.Write(shopId);
|
||||||
|
output.Write(",");
|
||||||
|
output.Write(baid);
|
||||||
|
output.Write(",");
|
||||||
|
output.Write(playedAt);
|
||||||
|
output.Write(",");
|
||||||
|
output.Write(isRight);
|
||||||
|
output.Write(",");
|
||||||
|
output.Write(type);
|
||||||
|
output.Write(",");
|
||||||
|
output.Write(amount);
|
||||||
|
output.WriteLine();
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Security.Authentication;
|
using System.Security.Authentication;
|
||||||
|
using Serilog.Sinks.File.Header;
|
||||||
|
using TaikoLocalServer.Logging;
|
||||||
using GameDatabase.Context;
|
using GameDatabase.Context;
|
||||||
using Microsoft.AspNetCore.HttpLogging;
|
using Microsoft.AspNetCore.HttpLogging;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
@ -40,7 +42,16 @@ try
|
|||||||
|
|
||||||
builder.Host.UseSerilog((context, configuration) =>
|
builder.Host.UseSerilog((context, configuration) =>
|
||||||
{
|
{
|
||||||
configuration.WriteTo.Console().ReadFrom.Configuration(context.Configuration);
|
configuration
|
||||||
|
.WriteTo.Console().ReadFrom.Configuration(context.Configuration)
|
||||||
|
.WriteTo.Logger(x =>
|
||||||
|
{
|
||||||
|
x.WriteTo.File(new CsvFormatter(),
|
||||||
|
path: "./Logs/HeadClerkLog-.csv",
|
||||||
|
hooks: new HeaderWriter("Date,ChassisId,ShopId,Baid,PlayedAt,IsRight,Type,Amount"),
|
||||||
|
rollingInterval: RollingInterval.Day);
|
||||||
|
x.Filter.ByIncludingOnly("StartsWith(@m, 'CSV WRITE:')");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (builder.Configuration.GetValue<bool>("ServerSettings:EnableMoreSongs"))
|
if (builder.Configuration.GetValue<bool>("ServerSettings:EnableMoreSongs"))
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
<PackageReference Include="protobuf-net.AspNetCore" Version="3.2.12" />
|
<PackageReference Include="protobuf-net.AspNetCore" Version="3.2.12" />
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
|
||||||
<PackageReference Include="Serilog.Expressions" Version="4.0.0-dev-00137" />
|
<PackageReference Include="Serilog.Expressions" Version="4.0.0-dev-00137" />
|
||||||
|
<PackageReference Include="Serilog.Sinks.File.Header" Version="1.0.2" />
|
||||||
<PackageReference Include="SharpZipLib" Version="1.4.2" />
|
<PackageReference Include="SharpZipLib" Version="1.4.2" />
|
||||||
<PackageReference Include="Swan.Core" Version="7.0.0-beta.2" />
|
<PackageReference Include="Swan.Core" Version="7.0.0-beta.2" />
|
||||||
<PackageReference Include="Swan.Logging" Version="6.0.2-beta.96" />
|
<PackageReference Include="Swan.Logging" Version="6.0.2-beta.96" />
|
||||||
|
Loading…
Reference in New Issue
Block a user