add logging
This commit is contained in:
+50
-4
@@ -62,18 +62,64 @@ builder.Services.AddSingleton<MessageRouter>();
|
||||
builder.Services.AddHealthChecks()
|
||||
.AddCheck<DatabaseHealthCheck>("mysql", tags: new[] { "ready" });
|
||||
|
||||
//var app = builder.Build();
|
||||
|
||||
//// DEBUG: Log registered handlers
|
||||
//var router = app.Services.GetRequiredService<MessageRouter>();
|
||||
//var handlers = app.Services.GetServices<IClientMessageHandler>();
|
||||
//foreach (var h in handlers)
|
||||
//{
|
||||
// app.Logger.LogInformation("Registered handler: {Type} with opcodes: {OpCodes}",
|
||||
// h.GetType().Name,
|
||||
// string.Join(", ", h.SupportedOpCodes));
|
||||
//}
|
||||
var app = builder.Build();
|
||||
|
||||
// DEBUG: Log registered handlers
|
||||
var router = app.Services.GetRequiredService<MessageRouter>();
|
||||
var handlers = app.Services.GetServices<IClientMessageHandler>();
|
||||
// DEBUG: Directly try to resolve each service
|
||||
app.Logger.LogInformation("=== DI Debug Start ===");
|
||||
|
||||
try
|
||||
{
|
||||
var serializer = app.Services.GetRequiredService<IMessageSerializer>();
|
||||
app.Logger.LogInformation("IMessageSerializer resolved: {Type}", serializer.GetType().Name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
app.Logger.LogError(ex, "Failed to resolve IMessageSerializer");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var matchMgr = app.Services.GetRequiredService<MatchManager>();
|
||||
app.Logger.LogInformation("MatchManager resolved OK");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
app.Logger.LogError(ex, "Failed to resolve MatchManager");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var gameHandler = app.Services.GetRequiredService<GameHandler>();
|
||||
app.Logger.LogInformation("GameHandler resolved OK, opcodes: {Ops}", string.Join(",", gameHandler.SupportedOpCodes));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
app.Logger.LogError(ex, "Failed to resolve GameHandler");
|
||||
}
|
||||
|
||||
var handlers = app.Services.GetServices<IClientMessageHandler>().ToList();
|
||||
app.Logger.LogInformation("IClientMessageHandler count: {Count}", handlers.Count);
|
||||
foreach (var h in handlers)
|
||||
{
|
||||
app.Logger.LogInformation("Registered handler: {Type} with opcodes: {OpCodes}",
|
||||
app.Logger.LogInformation(" Handler: {Type} with opcodes: {OpCodes}",
|
||||
h.GetType().Name,
|
||||
string.Join(", ", h.SupportedOpCodes));
|
||||
}
|
||||
|
||||
var router = app.Services.GetRequiredService<MessageRouter>();
|
||||
app.Logger.LogInformation("MessageRouter resolved OK");
|
||||
app.Logger.LogInformation("=== DI Debug End ===");
|
||||
|
||||
// ---- Health endpoints ----
|
||||
app.MapGet("/health/live", () => Results.Ok(new { status = "live" }));
|
||||
|
||||
Reference in New Issue
Block a user