fix(driver-cli-common): resolve Medium code-review finding (Driver.Cli.Common-003)
ConfigureLogging is now idempotent via a _loggingConfigured guard field so repeated calls from subclasses do not abandon and leak the previous logger. The previous Log.Logger is disposed before overwriting to release its console-sink resources cleanly. A new protected static FlushLogging() helper calls Log.CloseAndFlush() so commands can guarantee buffered output is flushed in their finally blocks before the process exits — important for the long-running subscribe verb. XML doc updated to reflect call-once semantics and document FlushLogging(). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -105,7 +105,7 @@ on the masked code (`code & 0xFFFF0000`).
|
||||
| Severity | Medium |
|
||||
| Category | Concurrency & thread safety |
|
||||
| Location | `src/Drivers/Cli/ZB.MOM.WW.OtOpcUa.Driver.Cli.Common/DriverCommandBase.cs:51-59` |
|
||||
| Status | Open |
|
||||
| Status | Resolved |
|
||||
|
||||
**Description:** `ConfigureLogging` assigns the process-global `Serilog.Log.Logger`
|
||||
without disposing the previously assigned logger and the library never calls
|
||||
@@ -121,7 +121,7 @@ command `ExecuteAsync`, or via a `protected` disposal helper on this base). Trea
|
||||
`ConfigureLogging` as call-once / idempotent and document that. At minimum capture and
|
||||
dispose the previous logger if reconfiguration is genuinely intended.
|
||||
|
||||
**Resolution:** _(open)_
|
||||
**Resolution:** Resolved 2026-05-22 — `ConfigureLogging` is now idempotent (guarded by `_loggingConfigured` field) and disposes the previous `Log.Logger` before overwriting; a new `protected static FlushLogging()` helper calls `Log.CloseAndFlush()` for commands to call in their `finally` blocks; XML doc updated accordingly.
|
||||
|
||||
### Driver.Cli.Common-004
|
||||
|
||||
|
||||
Reference in New Issue
Block a user