Add helpers for recording log messages to a string. Mainly of interest for tests that need to check whether a particular message has been written into the log.