If one of the log functions throws an uncaught exception, what is affected? Some possibilities - all of which you'd probably want to avoid - are:
- Some of the other loggers wouldn't fire
- The code that triggered the log() call would see the exception.
- The entire app might shut down
Now, if log destinations are explicitly try/catch wrapped, this is not an issue. But we might forget to do so. An Event Bus could help here. The event bus style of a logger would be: rather than composing multiple functions into a single one, each log destination becomes a bus listener. Let's say we have a dedicated Bus for logging, here's how we can write a log() function that puts a message on the bus for listener destinations to pick up: