feat(device): route DaqifiDevice diagnostics through an optional ILogger (part of #340) - #360
Conversation
…ger (part of #340) DaqifiDevice emitted all its diagnostics — including the bad-calibration/missing-resolution warnings that mean systematically wrong scaled samples — via Trace.WriteLine, invisible to consumers on Microsoft.Extensions.Logging. It now accepts an optional ILogger (default NullLogger), threaded via DeviceConnectionOptions.Logger through the factory, and all 12 Trace.WriteLine sites route through it with message templates: Warning for calibration/resolution anomalies, drain-not-converged, and classified-event subscriber exceptions; Debug for SCPI text-exchange timing. RaiseClassifiedEvent is now an instance method so it can log. Non-breaking (logger params are optional). Scope: this covers the central DaqifiDevice + factory reachability (acceptance criteria 1-2 of #340); finders/transports and the FirmwareUpdateService NullLogger default remain follow-ups, so this does NOT close #340. - 4 unit tests (bad resolution -> Warning through the injected logger; valid status -> no warning; no logger -> NullLogger, no throw; options.Logger defaults null). Core 1639 pass, MCP 23 pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
/agentic_review |
PR Summary by QodoRoute DaqifiDevice diagnostics through optional ILogger
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
Context used 1.
|
… throwing loggers Addresses two Qodo findings on #360: - Factory: ConnectFromDeviceInfoAsync's WiFi/serial paths rebuilt DeviceConnectionOptions without copying Logger, so the device silently fell back to NullLogger on the discovery path. Now the rebuilt options carry Logger = effectiveOptions.Logger. - Reliability: all 12 DaqifiDevice logger calls are now wrapped in SafeLog (mirrors MessageProducer.SafeLog) so a throwing consumer ILogger can't escape — most importantly in RaiseClassifiedEvent's catch, whose whole purpose is to isolate frame processing from faults. - New test: a throwing ILogger on the calibration-warning path is swallowed and does not propagate. Full suite 1640 pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Both fixed in the latest commit:
|
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 52abfc1 |
|
Qodo re-review clean (0 unresolved), CI green, full suite 1640 pass. Ready for review. |
The PR is clean from Qodo’s perspective: no unresolved findings remain, and the reported CI status is green with all 1,640 tests passing. It’s ready for review. |
Summary
DaqifiDeviceemitted all its diagnostics — including the bad-calibration / missing-resolution warnings that mean systematically wrong scaled samples — viaTrace.WriteLine, which the real consumers (onMicrosoft.Extensions.Logging) never see. It now accepts an optionalILogger(defaultNullLogger), reachable viaDeviceConnectionOptions.Loggerthrough the factory, and everyTrace.WriteLinesite routes through it. Non-breaking — the logger constructor params are optional.Changes
DaqifiDevice/DaqifiStreamingDeviceconstructors acceptILogger? logger = null(→NullLogger.Instance);DeviceConnectionOptions.Loggerthreads it throughDaqifiDeviceFactory.Trace.WriteLinesites inDaqifiDeviceconverted toILoggermessage templates (no interpolation —TreatWarningsAsErrors/CA2254 clean):PopulateAnalogChannelscalibration/resolution anomalies ("scaled samples may be systematically wrong/affected"), drain-queue-not-converged, and classified-event subscriber exceptions.ExecuteTextCommandAsynctiming chatter and drain-queue empty-reply termination.RaiseClassifiedEventis now an instance method so it can log via_logger.Testing
dotnet test— Core 1639 pass / 0 fail / 2 skipped, MCP 23 pass (net9.0 + net10.0).NullLoggerand doesn't throw on the warning path;DeviceConnectionOptions.Loggerdefaults null.Scope note
Covers acceptance criteria 1–2 of #340 (central
DaqifiDevice+ factory reachability). The remaining items — optional loggers on the finders/transports and aNullLoggerdefault forFirmwareUpdateService— are left for follow-up PRs. Does not close #340. Also note:Trace.WriteLineoutput is no longer emitted for non-opted-in consumers (they were not reliably consuming it — the feature's premise), diagnostics now flow toILogger.Not merging — for review.
🤖 Generated with Claude Code