This is the custom log handling code that I wrote and used extensively in my projects. It was originally created to handle logging serial and SSH console log which has huge amount of data.
This one uses queue so there is no performance bottleneck on the logging calls.