[OE-core] [PATCH 8/9] oe-build-perf-test: write logger output into file only
Markus Lehtonen
markus.lehtonen at linux.intel.com
Fri Aug 12 09:11:25 UTC 2016
Write the output from the Python logger only into the log file. This way
the console output from the script is cleaner and not mixed with the
logger records.
Signed-off-by: Markus Lehtonen <markus.lehtonen at linux.intel.com>
---
scripts/oe-build-perf-test | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/scripts/oe-build-perf-test b/scripts/oe-build-perf-test
index 786c715..e857ca6 100755
--- a/scripts/oe-build-perf-test
+++ b/scripts/oe-build-perf-test
@@ -33,10 +33,7 @@ from oeqa.buildperf import (BuildPerfTestLoader, BuildPerfTestResult,
from oeqa.utils.commands import runCmd
-# Set-up logging
-LOG_FORMAT = '[%(asctime)s] %(levelname)s: %(message)s'
-logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
-log = logging.getLogger()
+log = None
def acquire_lock(lock_f):
@@ -71,15 +68,18 @@ def pre_run_sanity_check():
return True
-def setup_file_logging(log_file):
+def setup_logging(log_file):
"""Setup loggin to file"""
+ global log
+
log_dir = os.path.dirname(log_file)
if not os.path.exists(log_dir):
os.makedirs(log_dir)
- formatter = logging.Formatter(LOG_FORMAT)
- handler = logging.FileHandler(log_file)
- handler.setFormatter(formatter)
- log.addHandler(handler)
+
+ log_format = '[%(asctime)s] %(levelname)s: %(message)s'
+ logging.basicConfig(level=logging.INFO, filename=log_file,
+ format=log_format)
+ log = logging.getLogger()
def archive_build_conf(out_dir):
@@ -112,6 +112,10 @@ def main(argv=None):
"""Script entry point"""
args = parse_args(argv)
+ # Set-up logging
+ out_dir = args.out_dir.format(date=datetime.now().strftime('%Y%m%d%H%M%S'))
+ setup_logging(os.path.join(out_dir, 'output.log'))
+
if args.debug:
log.setLevel(logging.DEBUG)
@@ -129,9 +133,6 @@ def main(argv=None):
# Load build perf tests
loader = BuildPerfTestLoader()
suite = loader.discover(start_dir=os.path.dirname(oeqa.buildperf.__file__))
- # Set-up log file
- out_dir = args.out_dir.format(date=datetime.now().strftime('%Y%m%d%H%M%S'))
- setup_file_logging(os.path.join(out_dir, 'output.log'))
# Run actual tests
archive_build_conf(out_dir)
--
2.6.6
More information about the Openembedded-core
mailing list