Check that the logger exists before logging.

In some conditions the logger can be nil, such as when testing.
Merge branch 'bugfix/logger-missing'