add write_log function