Add a scoped version of lock() and make locking nothrow.
Rewrite the logger to have pluggable output and more verbosity levels.

Non informational messages are now logged to stderr instead of stdout.
Split multi-line log messages into separate log lines.