Logging is important to me. I’ve been an SRE for Internet companies for a long time, and they’re often quite important.

On the Creature Controller, there is a Logger interface that the components use. I use the Dependency Injection pattern for getting the logger going.

Why use DI here? Because it makes writing uint tests easier. I’m able to abstract out the logger (there’s a MockLogger in the tests), which makes it cleaner to write and to test. I tend to use spdlog, but it doesn’t really matter since it’s abstracted out.

I’m still learning my way around unit tests and C++. This is a new world to me, but I’ve been converted. The complexity pays for itself in flexibility while testing.