log: use a RWMutex to protect access to the logger

This is kind of a revert of 7b91ec0286337ef7ed3e3f11776370664339d2a2.
It's an avoidance of data races in tests (I don't like the idea that
much, but let's do it).

Should fix the build in Jenkins.