From 8fea1e65c50c4366ce166690d4eb09a297efe070 Mon Sep 17 00:00:00 2001 From: Jack Wilsdon Date: Fri, 11 Sep 2015 18:01:36 +0100 Subject: [PATCH] Add logging for hook plugin --- beetsplug/hook.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/beetsplug/hook.py b/beetsplug/hook.py index c0747bce5..5d15a55aa 100644 --- a/beetsplug/hook.py +++ b/beetsplug/hook.py @@ -22,7 +22,7 @@ import sys from beets.plugins import BeetsPlugin -def create_hook_function(command, shell, substitute_args): +def create_hook_function(log, event, command, shell, substitute_args): # TODO: Find a better way of piping STDOUT/STDERR/STDIN between the process # and the user. @@ -47,6 +47,8 @@ def create_hook_function(command, shell, substitute_args): unicode(kwargs[key], "utf-8")) + log.debug('Running command {0} for event {1}', hook_command, event) + process = subprocess.Popen(hook_command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, @@ -98,8 +100,8 @@ class HookPlugin(BeetsPlugin): substitute_args = {} hook_command = hook_command.replace(original, hook_event) - hook_function = create_hook_function(hook_command, - shell, - substitute_args) + hook_function = create_hook_function(self._log, hook_event, + hook_command, shell, + substitute_args) self.register_listener(hook_event, hook_function)