Log-related fixes

- Avoid a crash when binary data is logged
- Do not write control characters from log messages
- Allow changing the log level as used for console messages