When implementing a global_logger, you must choose between a single-channel or multi-channel architecture depending on your concurrency requirements.
Single Logging Channel
All execution contexts (e.g., main and all interrupt handlers) share one channel.
- Synchronization: To prevent corruption,
acquire must disable interrupts and release must re-enable them. This synchronizes access across different priority levels. - Example:
defmt-semihosting uses this approach.
Multiple Logging Channels
Each priority level (or interrupt level) can have its own dedicated channel.
- Benefits: Allows for lock-free logging; interrupts do not need to be disabled during logging.
- Trade-offs: Higher memory usage on the target (for per-channel buffering) and potentially lower throughput (due to channel multiplexing or tagging).
- Transport Requirements: Requires a transport that supports multiplexing. RTT supports this natively. Other transports (like ITM) require log frames to be tagged with their channel ID.