Add mutex to protect localtime()
Refine logs