Add support for custom StringWriter interface to handle writing lines to log files.

@tolsen