This is the current working logging mechanism. It's not perfect and probably need to rewrite. The key thing here is to make it process-safe and thread-safe. Also, the child process need to inherit its parent process.