diff --git a/flamenco_worker/commands.py b/flamenco_worker/commands.py
index 2e1afa3634e70e05e3bbc1f155e11b89c5a4dd6b..e3b66647e886cc1d09e50dd999cbe13657a756dd 100644
--- a/flamenco_worker/commands.py
+++ b/flamenco_worker/commands.py
@@ -506,10 +506,12 @@ class AbstractSubprocessCommand(AbstractCommand):
                     await self.worker.register_log(processed_line)
 
             retcode = await self.proc.wait()
-            self._log.info('Command %r (pid=%d) stopped with status code %s', args, pid, retcode)
+            cmdline = ' '.join(shlex.quote(arg) for arg in args)
+            self._log.info('Command %r (pid=%d) stopped with status code %s', cmdline, pid, retcode)
 
             if retcode:
-                raise CommandExecutionError('Command pid=%d failed with status %s' % (pid, retcode))
+                raise CommandExecutionError('Command %r (pid=%d) failed with status %s' %
+                                            (cmdline, pid, retcode))
         except asyncio.CancelledError:
             self._log.info('asyncio task got canceled, killing subprocess pid=%d', pid)
             await self.abort()