From 1a7a561e486b64a051cd25c80f85ec69d3baf0f8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 2 Mar 2017 09:37:37 +0530 Subject: [PATCH] ... --- src/calibre/ebooks/metadata/sources/test.py | 5 +++++ src/calibre/utils/logging.py | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/calibre/ebooks/metadata/sources/test.py b/src/calibre/ebooks/metadata/sources/test.py index b9b967b5a9..67b185c24c 100644 --- a/src/calibre/ebooks/metadata/sources/test.py +++ b/src/calibre/ebooks/metadata/sources/test.py @@ -188,6 +188,7 @@ def test_identify(tests): # {{{ if not possibles: prints('ERROR: No results that passed all tests were found') prints('Log saved to', lf) + log.close() dump_log(lf) raise SystemExit(1) @@ -228,6 +229,9 @@ def test_identify_plugin(name, tests, modify_plugin=lambda plugin:None, times = [] for kwargs, test_funcs in tests: + log('#'*80) + log('### Running test with:', kwargs) + log('#'*80) prints('Running test with:', kwargs) rq = Queue() args = (log, rq, abort) @@ -278,6 +282,7 @@ def test_identify_plugin(name, tests, modify_plugin=lambda plugin:None, if not possibles: prints('ERROR: No results that passed all tests were found') prints('Log saved to', lf) + log.close() dump_log(lf) raise SystemExit(1) diff --git a/src/calibre/utils/logging.py b/src/calibre/utils/logging.py index eae37e7c65..6489b1d2f5 100644 --- a/src/calibre/utils/logging.py +++ b/src/calibre/utils/logging.py @@ -174,6 +174,16 @@ class Log(object): def __exit__(self, *args): self.filter_level = self.orig_filter_level + def flush(self): + for o in self.outputs: + if hasattr(o, 'flush'): + o.flush() + + def close(self): + for o in self.outputs: + if hasattr(o, 'close'): + o.close() + class DevNull(Log):