Fix TypeError when printing log messages.
Minor refactor.