refactor(battle-node): gate WS diagnostic logging behind config flag
The temporary [sio-in] / [sio-out] / [ws-rx-text] / [ws-rx-bin] /
[ws-recv-exit] / [ws-loop-exit] logs added during the hand-ack
investigation are useful enough to keep around (PvP testing, future WS
debugging) but too chatty to leave on by default. Promote them from
"strip before merge" to a permanent opt-in.
New BattleNodeOptions.DiagnosticLogging (bool, default false). Wired
through BattleNodeWebSocketHandler to RealParticipant via a new optional
ctor parameter (default false — existing test sites pick up the silent
default with no changes). Every Information/Warning log added during the
investigation is now if-gated; non-diagnostic logs (the decode-failure
warnings, the dispatch-drop debug) stay as-is.
Toggle via appsettings*.json:
"BattleNode": { "DiagnosticLogging": true }
Or live via the singleton:
factory.Services.GetRequiredService<BattleNodeOptions>().DiagnosticLogging = true
175 battle-node tests still passing — existing tests use the constructor
default and emit nothing, so no test changes were required.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -124,7 +124,7 @@ public sealed class BattleNodeWebSocketHandler
|
||||
{
|
||||
_store.RemovePending(battleId);
|
||||
var realParticipant = new RealParticipant(ws, viewerId, pending.P1.Context,
|
||||
_loggerFactory.CreateLogger<RealParticipant>());
|
||||
_loggerFactory.CreateLogger<RealParticipant>(), _options.DiagnosticLogging);
|
||||
var scriptedBot = new ScriptedBotParticipant();
|
||||
var session = new BattleSession(battleId, pending.Type, realParticipant, scriptedBot,
|
||||
_loggerFactory.CreateLogger<BattleSession>());
|
||||
@@ -137,7 +137,7 @@ public sealed class BattleNodeWebSocketHandler
|
||||
// Pick this connection's MatchContext (P1's if isP1, P2's if isP2).
|
||||
var selfCtx = isP1 ? pending.P1.Context : pending.P2!.Context;
|
||||
var self = new RealParticipant(ws, viewerId, selfCtx,
|
||||
_loggerFactory.CreateLogger<RealParticipant>());
|
||||
_loggerFactory.CreateLogger<RealParticipant>(), _options.DiagnosticLogging);
|
||||
|
||||
var firstArriver = _waitingRoom.Pair(battleId, self);
|
||||
|
||||
@@ -202,7 +202,7 @@ public sealed class BattleNodeWebSocketHandler
|
||||
// earlier isP1/isP2 check has already rejected viewer mismatches.
|
||||
_store.RemovePending(battleId);
|
||||
var botReal = new RealParticipant(ws, viewerId, pending.P1.Context,
|
||||
_loggerFactory.CreateLogger<RealParticipant>());
|
||||
_loggerFactory.CreateLogger<RealParticipant>(), _options.DiagnosticLogging);
|
||||
var noopBot = new NoOpBotParticipant();
|
||||
var botSession = new BattleSession(battleId, BattleType.Bot, botReal, noopBot,
|
||||
_loggerFactory.CreateLogger<BattleSession>());
|
||||
|
||||
Reference in New Issue
Block a user