Event Logging

When everything is going well, there is no need for event logs. How often do things go well?

When something goes sideways, you will probably want to perform a post mortem on the system and figure out why things went wrong. For that, you will need data. Unfortunately, embedded systems are often secretive about their internal goings on. Telemetry and event logs can help, but they are not a panacea.

Since problems can manifest anywhere in the software, event logging is a cross-cutting concern. Additionally, real-time systems have constraints that can't be violated by a poorly implemented event logger.

Event logging is one of the few places I recommend using a singleton. Since any code anywhere in the system might need to log something, dependency injection is not practical.

I also recommend using C++ macros to wrap the event logging code such that there is a clean interface at the call site.

Introduction