trap_err: print log prior to exit