feat(native): collector logging parity — built-in file logger + events + tests#1221
Conversation
…work)
The .NET HSMDataCollector logs a full Info/Debug/Error spectrum and ships an NLog
file sink by default; the native collector only emitted Error at a few sites with no
built-in file output. tt-aggregator2's team (writing their own native adapter) needs
those logs. This lands the logging framework:
- FileLogger: async, date-rolling file sink (background thread + queue) writing
<dir>/DataCollector_<UTC-date>.txt (levels >= min_level) + _error_ (errors only),
format "yyyy-MM-dd HH:mm:ss|LEVEL| message"; drains the queue on shutdown.
- EnableFileLogging (C ABI hsm_collector_enable_file_logging + C++ Collector::) installs
it; complements SetLogger - both sinks receive every message via the one LogMessage path.
- Info lifecycle logs ("DataCollector -> Starting/Running/Stopping/Stopped") in NotifyLifecycle.
Follow-ups: remaining events (sensor registration, send failure/retry, runtime queue
drop, value rejection) + unit tests + feature.md.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
PR #1221 Review — Native collector file loggingOverall this is a clean, well-structured addition. The 1. (Medium) Use-after-free window if
|
Code Review — PR #1221
|
Completes the logging-parity work over the file-logger framework: - Send diagnostics: HttpSendBatch logs "Failed to send N value(s): HTTP <code> ..." (Error, deduplicated) on a failed batch; the /commands POST on Start logs "Registered N sensor(s) on connect" (Info) alongside the existing failure Error. - Tests: native_logging_emits_lifecycle_events (callback sees the Info lifecycle transitions) + native_file_logger_writes_to_dated_file (EnableFileLogging writes a dated file with the line + level, flushed deterministically by the destructor). - feature.md: full logging section (sinks, file layout/format/rotation, event catalog, and the deliberate parity delta — per-sensor Info + value-rejection Debug are not emitted to avoid logging under the collector lock / sensor plumbing). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
PR #1221 Review — Native collector logging (built-in file sink + lifecycle/send diagnostics)Nice, well-documented change. The 1. Potential use-after-free when
|
Brings the native collector's logging toward parity with the managed HSMDataCollector, for tt-aggregator2's native adapter (they miss the .NET logs).
This PR (framework + first events):
FileLogger: async, date-rolling built-in file sink (DataCollector_<UTC-date>.txt+_error_,yyyy-MM-dd HH:mm:ss|LEVEL| message), drains on shutdown.hsm_collector_enable_file_logging(C ABI) +Collector::EnableFileLogging(C++) - complementsSetLogger; both sinks get every message.NotifyLifecycle.Still to add (same PR): sensor-registration / send-failure+retry (attempt#/HTTP code) / runtime queue-drop / value-rejection events, unit tests, and
feature.md. Opening now to get the native build/conformance/sanitizers lanes on the framework code.🤖 Generated with Claude Code