Use write() directly rather than std::cerr. This avoids mixing logs from
different threads.
Fix the build.
Merge pull request #436 from nomis52/master

Fix the mangled text when logging from multiple threads.
Merge remote-tracking branch 'remotes/upstream/master'
Added missing include directive