Revised logging system to be more functional and safe and use STL and C++11 features.

Logging system now features among other thinngs: automagically starting and cleaning up (while waiting for all messages to be printed), automatic thread idle state when waiting for messages, automatic prefixing when outputting newlines.