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:
@@ -40,10 +40,14 @@ public static class WorkerApplication
|
||||
/// CLR's crash code.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Logs the exception type only — never its message or stack, which
|
||||
/// can carry tag values or credentials passed through a command — the
|
||||
/// same rule every other worker failure line follows. A logging
|
||||
/// failure is swallowed so the exit always happens.
|
||||
/// Logs the exception type only — never its message or stack. An
|
||||
/// exception reaching this hook can come from any thread, including a
|
||||
/// COM callback or a command path whose message can carry tag values
|
||||
/// or credentials, so it gets none of the content that
|
||||
/// <see cref="Run(string[], IWorkerEnvironment, IWorkerLogger, IWorkerPipeClient)"/>'s
|
||||
/// own catch blocks log through <see cref="WorkerLogRedactor.RedactMessage"/>
|
||||
/// (those see only pipe-session failures). A logging failure is
|
||||
/// swallowed so the exit always happens.
|
||||
/// </remarks>
|
||||
/// <param name="logger">Worker logger.</param>
|
||||
/// <param name="exceptionObject">The unhandled exception object (not necessarily an <see cref="Exception"/>).</param>
|
||||
@@ -171,6 +175,7 @@ public static class WorkerApplication
|
||||
["exit_code"] = WorkerExitCode.PipeConnectionFailed,
|
||||
["error_code"] = exception.ErrorCode,
|
||||
["exception_type"] = exception.GetType().FullName,
|
||||
["exception_message"] = WorkerLogRedactor.RedactMessage(exception.Message),
|
||||
});
|
||||
|
||||
return (int)WorkerExitCode.PipeConnectionFailed;
|
||||
@@ -182,6 +187,7 @@ public static class WorkerApplication
|
||||
["exit_code"] = WorkerExitCode.ProtocolViolation,
|
||||
["error_code"] = exception.ErrorCode,
|
||||
["exception_type"] = exception.GetType().FullName,
|
||||
["exception_message"] = WorkerLogRedactor.RedactMessage(exception.Message),
|
||||
});
|
||||
|
||||
return (int)WorkerExitCode.ProtocolViolation;
|
||||
@@ -193,6 +199,7 @@ public static class WorkerApplication
|
||||
{
|
||||
["exit_code"] = WorkerExitCode.EventQueueOverflow,
|
||||
["exception_type"] = exception.GetType().FullName,
|
||||
["exception_message"] = WorkerLogRedactor.RedactMessage(exception.Message),
|
||||
});
|
||||
|
||||
return (int)WorkerExitCode.EventQueueOverflow;
|
||||
@@ -203,6 +210,7 @@ public static class WorkerApplication
|
||||
{
|
||||
["exit_code"] = WorkerExitCode.PipeConnectionFailed,
|
||||
["exception_type"] = exception.GetType().FullName,
|
||||
["exception_message"] = WorkerLogRedactor.RedactMessage(exception.Message),
|
||||
});
|
||||
|
||||
return (int)WorkerExitCode.PipeConnectionFailed;
|
||||
@@ -213,6 +221,7 @@ public static class WorkerApplication
|
||||
{
|
||||
["exit_code"] = WorkerExitCode.UnexpectedFailure,
|
||||
["exception_type"] = exception.GetType().FullName,
|
||||
["exception_message"] = WorkerLogRedactor.RedactMessage(exception.Message),
|
||||
});
|
||||
|
||||
return (int)WorkerExitCode.UnexpectedFailure;
|
||||
|
||||
Reference in New Issue
Block a user