C code to write logs using a different thread. Inspired from https://github.com/zma/zlog