From: David Lehman dlehman@redhat.com
--- blivet/util.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/blivet/util.py b/blivet/util.py index 8a96350..f6cbc03 100644 --- a/blivet/util.py +++ b/blivet/util.py @@ -29,6 +29,7 @@ log = logging.getLogger("blivet") program_log = logging.getLogger("program") testdata_log = logging.getLogger("testdata") +console_log = logging.getLogger("blivet.console")
from threading import Lock # this will get set to anaconda's program_log_lock in enable_installer_mode @@ -731,12 +732,13 @@ def dedup_list(alist): ##
-def set_up_logging(log_dir="/tmp", log_prefix="blivet"): +def set_up_logging(log_dir="/tmp", log_prefix="blivet", console_logs=None): """ Configure the blivet logger to write out a log file.
- :keyword str log_file: path to the log file (default: /tmp/blivet.log) + :keyword str log_dir: path to directory where log files are + :keyword str log_prefix: prefix for log file names + :keyword list console_logs: list of log names to output on the console """ - log.setLevel(logging.DEBUG) program_log.setLevel(logging.DEBUG)
@@ -757,6 +759,9 @@ def make_handler(path, prefix, level): warning_log = logging.getLogger("py.warnings") warning_log.addHandler(handler)
+ if console_logs: + set_up_console_log(log_names=console_logs) + log.info("sys.argv = %s", sys.argv)
prefix = "%s-testdata" % (log_prefix,) @@ -765,6 +770,18 @@ def make_handler(path, prefix, level): testdata_log.addHandler(handler)
+def set_up_console_log(log_names=None): + log_names = log_names or [] + handler = logging.StreamHandler() + console_log.setLevel(logging.DEBUG) + handler.setLevel(logging.DEBUG) + formatter = logging.Formatter("%(threadName)s: %(message)s") + handler.setFormatter(formatter) + console_log.addHandler(handler) + for name in log_names: + logging.getLogger(name).addHandler(handler) + + def create_sparse_tempfile(name, size): """ Create a temporary sparse file.
anaconda-patches@lists.fedorahosted.org