The constructor of `CLogger::LifetimeGuard` does initialize `g_Logger` and the destructor resets it.
`TestLogger`, `TestStdoutLogger` and the new `EngineLogger` use store an object of it alongside some costum data.
Previously `g_Logger` was reset to `nullptr`. Now it's reset to the previous `CLogger` (the `nullLogger`).
Now the `CLogger` is stored on the stack instead of dynamic memory.
The message "Engine exited successfully" might be logged even if an exception is thrown. That could be change using `std::uncaught_exceptions`.
I strive to introduse such "guards" for more globals.
Which is the best name:
- `LifetimeGuard` It manages the lifetime of an external object.
- `InitGuard` Other such classes might not be about lifetime.
- `ScopedLifetime` Because it does something on scope exit.
- `ScopedGuard` one might think it's a combination of `std::scoped_lock` and `std::lock_guard`.
Should it be `CLogger::LifetimeGuard` or `LifetimeGuard<CLogger>`?