make write log immediately after calling to prevent lose log info when program crash