The constructor does initialize `g_Logger` and the destructor resets it.
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 can be change using `std::current_exception`.
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>`?
Should it be explicitly non-moveable? It doesn't make a difference in this case but it might make in others...