context manager to conditionally silence log messages