fix over/under flow when log is disabled.