From: Cédric Ollivier Date: Wed, 24 Apr 2019 19:08:37 +0000 (+0200) Subject: Enable debug messages via env var X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F89%2F67689%2F1;p=functest-xtesting.git Enable debug messages via env var It stops printing in xtesting.debug.log by default. It decreases testing duration via Raspberry PI without additional tasks [1]. [1] https://wiki.opnfv.org/display/functest/Run+Functest+containers+on+Raspberry+PI Change-Id: I2eded47a7a150a45330a69f3262fc7ca6fdb7463 Signed-off-by: Cédric Ollivier --- diff --git a/xtesting/ci/logging.debug.ini b/xtesting/ci/logging.debug.ini new file mode 100644 index 00000000..1c8d136a --- /dev/null +++ b/xtesting/ci/logging.debug.ini @@ -0,0 +1,60 @@ +[loggers] +keys=root,xtesting,ci,core,warnings + +[handlers] +keys=console,wconsole,file,dfile + +[formatters] +keys=standard + +[logger_root] +level=NOTSET +handlers=dfile + +[logger_xtesting] +level=NOTSET +handlers=file +qualname=xtesting + +[logger_ci] +level=NOTSET +handlers=console +qualname=xtesting.ci + +[logger_core] +level=NOTSET +handlers=console +qualname=xtesting.core + +[logger_warnings] +level=NOTSET +handlers=file,console +qualname=py.warnings + +[handler_console] +class=StreamHandler +level=INFO +formatter=standard +args=(sys.stdout,) + +[handler_wconsole] +class=StreamHandler +level=WARN +formatter=standard +args=(sys.stdout,) + +[handler_file] +class=FileHandler +level=DEBUG +formatter=standard +args=("/var/lib/xtesting/results/xtesting.log",) + +[handler_dfile] +class=FileHandler +level=DEBUG +formatter=standard +args=("/var/lib/xtesting/results/xtesting.debug.log",) + +[formatter_standard] +format=%(asctime)s - %(name)s - %(levelname)s - %(message)s +datefmt= diff --git a/xtesting/ci/logging.ini b/xtesting/ci/logging.ini index 1c8d136a..a63e406a 100644 --- a/xtesting/ci/logging.ini +++ b/xtesting/ci/logging.ini @@ -2,14 +2,14 @@ keys=root,xtesting,ci,core,warnings [handlers] -keys=console,wconsole,file,dfile +keys=console,wconsole,file,null [formatters] keys=standard [logger_root] level=NOTSET -handlers=dfile +handlers=null [logger_xtesting] level=NOTSET @@ -31,6 +31,12 @@ level=NOTSET handlers=file,console qualname=py.warnings +[handler_null] +class=NullHandler +level=NOTSET +formatter=standard +args=() + [handler_console] class=StreamHandler level=INFO @@ -49,12 +55,6 @@ level=DEBUG formatter=standard args=("/var/lib/xtesting/results/xtesting.log",) -[handler_dfile] -class=FileHandler -level=DEBUG -formatter=standard -args=("/var/lib/xtesting/results/xtesting.debug.log",) - [formatter_standard] format=%(asctime)s - %(name)s - %(levelname)s - %(message)s datefmt= diff --git a/xtesting/ci/run_tests.py b/xtesting/ci/run_tests.py index c8e99663..94bf2787 100644 --- a/xtesting/ci/run_tests.py +++ b/xtesting/ci/run_tests.py @@ -307,8 +307,12 @@ def main(): if ex.errno != errno.EEXIST: six.print_("Cannot create /var/lib/xtesting/results/") return testcase.TestCase.EX_RUN_ERROR - logging.config.fileConfig(pkg_resources.resource_filename( - 'xtesting', 'ci/logging.ini')) + if env.get('DEBUG').lower() == 'true': + logging.config.fileConfig(pkg_resources.resource_filename( + 'xtesting', 'ci/logging.debug.ini')) + else: + logging.config.fileConfig(pkg_resources.resource_filename( + 'xtesting', 'ci/logging.ini')) logging.captureWarnings(True) parser = RunTestsParser() args = parser.parse_args(sys.argv[1:]) diff --git a/xtesting/utils/env.py b/xtesting/utils/env.py index f17d78a1..df06cb7b 100644 --- a/xtesting/utils/env.py +++ b/xtesting/utils/env.py @@ -15,6 +15,7 @@ import prettytable INPUTS = { 'CI_LOOP': 'daily', + 'DEBUG': 'false', 'DEPLOY_SCENARIO': 'os-nosdn-nofeature-noha', 'INSTALLER_TYPE': 'unknown', 'BUILD_TAG': None,