[Reviewer: Andy] Rework the fake logger used in UTs

Most of this is self-explanatory, but I saw a lot of memory corruption when running UTs (particularly the 'this' pointer of my HSSConnection being set to '2'). I don't believe this was caused by these changes - I could reproduce them on other branches - and I suspect I saw them because this laptop is slower than my ordinary PC and race conditions happen differently. I think this is the same issue as https://github.com/Metaswitch/sprout/issues/606 - it really annoyed me, so I resolved it by putting locks in Log::write and Log::set_logger to avoid threads trampling on each other.

Should be safe, performance-wise, for production - log levels are typically low there, and I made sure that checking the log level (and doing nothing if it's too high) comes before trying to acquire the lock.
Good question. I don't think you can call Log::setLogger(NULL) here, because the CapturingTestLogger destructor will get the default test logger to take over, but it's a subclass of this, so this destructor would then get called and unset it.

Maybe the answer is that CapturingTestLogger shouldn't inherit from PrintingTestLogger (and then we could hide PrintingTestLogger's constructor and make it a proper singleton). Thoughts?

(In practice, currently, it's not a problem as PrintingTestLogger::DEFAULT stays around until the program ends.)