Fix handling of newlines in log messages