Allow QuiteLogger to hide custom log level

By default we want to hide all messages except errors but in several cases
(like assert_ha_services_ready) we need to suppress error messages too.

Change-Id: I513c73055f0e517b308868b1cd500a185ea81be2
(cherry picked from commit 8c52fd4aef)
This commit is contained in:
Vladimir Khlyunev 2016-03-28 16:52:04 +03:00
parent 91029af517
commit e9a251af28
2 changed files with 9 additions and 3 deletions

View File

@ -75,8 +75,13 @@ logwrap = debug(logger)
class QuietLogger(object):
"""Reduce logging level while context is executed."""
def __init__(self, upper_log_level=logging.WARNING):
self.log_level = upper_log_level
self.storage = None
def __enter__(self):
console.setLevel(logging.ERROR)
self.storage = console.level
console.setLevel(self.log_level + 1)
def __exit__(self, exp_type, exp_value, traceback):
console.setLevel(logging.INFO)
console.setLevel(self.storage)

View File

@ -14,6 +14,7 @@
from __future__ import division
import logging
import re
import time
import traceback
@ -172,7 +173,7 @@ class FuelWebClient(object):
if self.get_cluster_mode(cluster_id) == DEPLOYMENT_MODE_HA:
logger.info('Waiting {0} sec. for passed OSTF HA tests.'
.format(timeout))
with QuietLogger():
with QuietLogger(logging.ERROR):
_wait(lambda: self.run_ostf(cluster_id,
test_sets=['ha'],
should_fail=should_fail),