Add some conditions that should prevent logging errors