From d15cc07ed3a49fda51ac0cc7486abf7591aff225 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 10 Sep 2015 19:25:58 +0200 Subject: [PATCH] Log executed command for GUIProcess. See #797. --- qutebrowser/misc/guiprocess.py | 3 ++- tests/unit/misc/test_guiprocess.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/qutebrowser/misc/guiprocess.py b/qutebrowser/misc/guiprocess.py index 0d11efffa..2c4c4f0a2 100644 --- a/qutebrowser/misc/guiprocess.py +++ b/qutebrowser/misc/guiprocess.py @@ -125,8 +125,9 @@ class GUIProcess(QObject): raise ValueError("Trying to start a running QProcess!") self.cmd = cmd self.args = args + fake_cmdline = ' '.join(shlex.quote(e) for e in [cmd] + list(args)) + log.procs.debug("Executing: {}".format(fake_cmdline)) if self.verbose: - fake_cmdline = ' '.join(shlex.quote(e) for e in [cmd] + list(args)) message.info(self._win_id, 'Executing: ' + fake_cmdline) def start(self, cmd, args, mode=None): diff --git a/tests/unit/misc/test_guiprocess.py b/tests/unit/misc/test_guiprocess.py index 21607d5c3..2212f7068 100644 --- a/tests/unit/misc/test_guiprocess.py +++ b/tests/unit/misc/test_guiprocess.py @@ -176,6 +176,17 @@ def test_cmd_args(fake_proc): assert (fake_proc.cmd, fake_proc.args) == (cmd, args) +def test_start_logging(fake_proc, caplog): + """Make sure that starting logs the executed commandline.""" + cmd = 'does_not_exist' + args = ['arg', 'arg with spaces'] + with caplog.atLevel(logging.DEBUG): + fake_proc.start(cmd, args) + msgs = [e.msg for e in caplog.records()] + assert msgs == ["Starting process.", + "Executing: does_not_exist arg 'arg with spaces'"] + + def test_error(qtbot, proc, caplog, guiprocess_message_mock): """Test the process emitting an error.""" with caplog.atLevel(logging.ERROR, 'message'):