Add structured logging infrastructure (#56)#60
Merged
Conversation
…ns.Logging package reference - Document decision to use ILogger DI injection via Host.SetLoggerFactory() - Define log event structure, category hierarchy, and EventId ranges - Plan WebRTC log sink with lock-free .NET Channel threading model - Add Microsoft.Extensions.Logging v9.0.0 to WebRtcNet.Api and WebRtcNet Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add WebRtcLogEventId enum with ranges (WebRTC 1000-1999, Media 2000-2999, Interop 3000-3999) - Add WebRtcLogEvent record capturing Timestamp, Severity, EventId, Category, ThreadId, Message - Add LogCategoryMapping class to parse JSON and map WebRTC tags to categories via regex - Add LogCategoryMapping.json resource with tag-to-category patterns - Add LoggerFactoryHolder with thread-safe factory holder and default console logger for Debug builds - Add Host.SetLoggerFactory() public API for apps to inject ILoggerFactory - Add Microsoft.Extensions.Logging package reference to both WebRtcNet.Api and WebRtcNet Phase 1 establishes baseline managed logging infrastructure ready for C++/CLI interop bridge. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add IWebRtcLogWriter interface for C++/CLI to call - Add WebRtcLogWriter with lock-free .NET Channel and background dequeue task - Logs enqueued from native threads, dequeued to ILogger by category - Graceful shutdown with channel closure and task timeout - Add WebRtcLogWriterBridge singleton exposing writer to C++/CLI Phase 2 establishes thread-safe channel infrastructure ready for C++/CLI log sink. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add MarshalLogging.h with marshal_as specialization for rtc::LoggingSeverity->LogLevel using map - Add WebRtcLogSink.h/cpp custom rtc::LogSink to capture all WebRTC diagnostics - OnLogMessage extracts tag, severity, message and forwards to managed writer via channel - Register log sink with WebRTC in RtcPeerConnectionFactory (eager initialization) - Add sink to WebRtcInterop.Shared.vcxitems project Phase 3 completes C++/CLI logging infrastructure; logs now flow from WebRTC → managed ILogger. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implements #56. Adds ILogger injection via Host.SetLoggerFactory(), a .NET Channel-backed log writer bridging native WebRTC threads to managed loggers, a C++/CLI rtc::LogSink capturing WebRTC library diagnostics, and enriched HRESULT failure logging in MediaDevices. Managed layer (WebRtcNet.Api): - WebRtcLogEventId enum with category ranges (WebRTC 1000-1999, Media 2000-2999, Interop 3000-3999) - WebRtcLogEvent record (Timestamp, Severity, EventId, Category, ThreadId, Message) - LogCategoryMapping: JSON resource mapping WebRTC tags to categories via regex, loaded from embedded LogCategoryMapping.json - LoggerFactoryHolder: thread-safe factory holder; Debug builds default to console logger, Release builds silent unless configured - WebRtcLogWriter: Channel + background dequeue task - WebRtcLogWriterBridge: public bridge exposing WriteInteropLog and ResolveWebRtcCategory for C++/CLI callers - Host.SetLoggerFactory() public API Interop layer (WebRtcInterop): - Logging/WebRtcLogSink: rtc::LogSink registered eagerly on RtcPeerConnectionFactory creation; uses marshal_as for string conversion; routes through WebRtcLogWriterBridge - Logging/InteropHResult: adds LogIfFailed() alongside ThrowIfFailed(); formats HRESULT with facility, code, and FormatMessageW system text - Logging/Marshaling/MarshalLogging.h: removed (severity converted via switch in WebRtcLogSink using int passthrough to WriteInteropLog) - MediaDevices: all COM HRESULT failure points now call LogIfFailed Tests: - WebRtcNet.Api.UnitTests/LoggingInfrastructureTests.cs: category mapping resolution, EventId ranges, WebRtcLogWriter channel forwarding - WebRtcInterop.UnitTests/InteropHResultTests.cpp: LogIfFailed return value for success and failure HRESULTs Documentation: - README: logging setup section with Host.SetLoggerFactory example - docs/adr/0003-logging-infrastructure.md: architecture decisions - WebRtcLogEventId: XML doc comments on all enum members BugzId:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements issue #56. Adds a full structured logging pipeline spanning managed code, C++/CLI interop, and the native WebRTC library. Logging is surfaced via \Microsoft.Extensions.Logging.ILoggerFactory\ injected through \Host.SetLoggerFactory(). Debug builds default to a console logger if no factory is provided.
Change Area (required)
Required Evidence (for behavioral/API changes)
N/A - no behavioral change (logging infrastructure only; no WebRTC or Media Capture behavior is added or altered)
1) W3C reference (required when applicable)
N/A
2) Google source reference (required when applicable)
N/A
3) Intended observable behavior (required when applicable)
N/A
4) Divergence from Google reference (required if diverging)
Test Evidence (required)
Tests added/updated
Commands run + results
Passed: 110, Failed: 0 — net10.0-windows and net48
All tests passed (Framework x64 Debug)
Change-area test gate confirmation
If environment unavailable (required when checked above)
N/A
Documentation
Spec/Crosswalk Review (required for W3C-aligned behavior changes)
N/A — logging infrastructure does not affect W3C-aligned API surface