Added flag for only logging errors (as opposed to throwing)