Fixed-capacity logger that formats records before dispatching to sinks.
- Template Parameters
-
| MaxSinks | Maximum number of attached structured log sinks. |
| MsgBufferCapacity | Capacity of each formatted message payload. |
| Mutex | BasicLockable type (lock()/unlock()) serializing calls to log()/flush()/add_sink() across threads. Defaults to a no-op lock, so concurrent callers may interleave ("slice") sink writes; pass e.g. std::mutex to serialize them instead when a single logger instance is shared across threads doing normal (non-signal-handler) logging. |
| Sink | Sink handle type stored by the logger (log_sink by default; see extended_logger for advanced sinks). |
| Decorator | Callable mapping the formatted log_msg to what sinks receive (identity by default; extended_logger adds execution metadata). |
- Warning
basic_logger is intended for normal program operation only, and must never be reused from a signal/crash handler regardless of Mutex choice: a blocking mutex can deadlock if the signal lands on a thread that already holds it, and several sink backends (buffered stdio, syslog, the systemd journal) aren't async-signal-safe to begin with. Crash handlers must set up their own dedicated, minimal sink chain built directly on an async-signal-safe primitive such as fd_sink (see crash_handler_demo.cpp) instead of routing through an application's basic_logger.