Avoid some memory copying when logging.
Merge pull request #569 from unknownbrackets/perf

Avoid some memory copying when logging