feat(worker): log exception messages and per-command start/end (mxaccessgw#184)
R21-O3: WorkerApplication.Run's failure lines logged only the exception type. Each now also carries exception_message, scrubbed by the new WorkerLogRedactor.RedactMessage: the value of any name=value / name: value pair whose name looks sensitive and any mxgw_ API key token are replaced, line breaks are flattened and the text is capped at 512 characters. The AppDomain unhandled-exception hook stays type-only, since an exception from an arbitrary thread can carry command values. R21-O7: StaCommandDispatcher.ExecuteQueuedCommandAsync logs WorkerCommandStarted (correlation id, method, queued_ms) and WorkerCommandCompleted (status, HRESULT, elapsed_ms) when a CommandLogger is set. IWorkerLogger has no Debug level, so the lines are opt-in through MXGATEWAY_WORKER_LOG_COMMANDS=1|true (WorkerCommandLogging), which the worker inherits from the gateway process environment. No payloads or diagnostic messages are logged. Docs updated. (mxaccessgw#184) Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
@@ -76,7 +76,7 @@ public sealed class WorkerPipeSession
|
||||
options,
|
||||
() => Process.GetCurrentProcess().Id,
|
||||
new WorkerPipeSessionOptions(),
|
||||
() => new MxAccessStaSession((eq, affinity, comFactory, pump) => new AlarmCommandHandler(eq, () => new WnWrapAlarmConsumer(), affinity, comFactory, standbyFactory: null, ackPumpStep: pump)),
|
||||
() => CreateDefaultRuntimeSession(WorkerCommandLogging.IsEnabled() ? logger : null),
|
||||
logger,
|
||||
stream)
|
||||
{
|
||||
@@ -98,7 +98,7 @@ public sealed class WorkerPipeSession
|
||||
options,
|
||||
processIdProvider,
|
||||
new WorkerPipeSessionOptions(),
|
||||
() => new MxAccessStaSession((eq, affinity, comFactory, pump) => new AlarmCommandHandler(eq, () => new WnWrapAlarmConsumer(), affinity, comFactory, standbyFactory: null, ackPumpStep: pump)),
|
||||
() => CreateDefaultRuntimeSession(commandLogger: null),
|
||||
logger: null)
|
||||
{
|
||||
}
|
||||
@@ -138,6 +138,19 @@ public sealed class WorkerPipeSession
|
||||
_sessionOptions.Validate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the production runtime session: MXAccess on its own STA with the wnwrap alarm
|
||||
/// consumer. <paramref name="commandLogger"/> receives the per-command start/end lines when
|
||||
/// non-null; the caller decides that through <see cref="WorkerCommandLogging"/>.
|
||||
/// </summary>
|
||||
private static MxAccessStaSession CreateDefaultRuntimeSession(IWorkerLogger? commandLogger)
|
||||
{
|
||||
return new MxAccessStaSession((eq, affinity, comFactory, pump) => new AlarmCommandHandler(eq, () => new WnWrapAlarmConsumer(), affinity, comFactory, standbyFactory: null, ackPumpStep: pump))
|
||||
{
|
||||
CommandLogger = commandLogger,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Runs the worker session, completing the handshake and processing messages until cancellation.</summary>
|
||||
/// <param name="cancellationToken">Token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
|
||||
Reference in New Issue
Block a user