[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.
Happy to rename to .h, less happy to append __. Per the C++ standard:

Certain sets of names and function signatures are always reserved to the implementation:
—
Each name that contains a double underscore __ or begins with an underscore followed by an uppercase
letter is reserved to the implementation for any use.

See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf, section 17.6.4.3.2.

Happy to email the team seeking agreement on this change.