public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 8/9] oe-build-perf-test: write logger output into file only
Date: Fri, 12 Aug 2016 12:11:25 +0300	[thread overview]
Message-ID: <1470993086-23718-9-git-send-email-markus.lehtonen@linux.intel.com> (raw)
In-Reply-To: <1470993086-23718-1-git-send-email-markus.lehtonen@linux.intel.com>

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@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



  parent reply	other threads:[~2016-08-12  9:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-12  9:11 [PATCH 0/9] oe-build-perf-test: use Python unittest framework Markus Lehtonen
2016-08-12  9:11 ` [PATCH 1/9] oeqa.buildperf: rename module containing basic tests Markus Lehtonen
2016-08-12  9:11 ` [PATCH 2/9] oeqa.buildperf: derive BuildPerfTestCase class from unitest.TestCase Markus Lehtonen
2016-08-12  9:11 ` [PATCH 3/9] oeqa.buildperf: add BuildPerfTestLoader class Markus Lehtonen
2016-08-12  9:11 ` [PATCH 4/9] oeqa.buildperf: add BuildPerfTestResult class Markus Lehtonen
2016-08-12  9:11 ` [PATCH 5/9] oeqa.buildperf: convert test cases to unittest Markus Lehtonen
2016-08-12  9:11 ` [PATCH 6/9] oe-build-perf-test: use new unittest based framework Markus Lehtonen
2016-08-12  9:11 ` [PATCH 7/9] oeqa.buildperf: introduce runCmd2() Markus Lehtonen
2016-08-12  9:11 ` Markus Lehtonen [this message]
2016-08-12  9:11 ` [PATCH 9/9] oeqa.buildperf: be more verbose about failed commands Markus Lehtonen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470993086-23718-9-git-send-email-markus.lehtonen@linux.intel.com \
    --to=markus.lehtonen@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox