add safe_snprintf
change all loga to log_safe in signal handler.