From 83c411b308e7d8ddb8897e922d6f985e9b92f68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 19 Oct 2020 11:03:21 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20Logging=20for=20start/pause/resu?= =?UTF-8?q?me/cancel=20print?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Always logs responsible user or plugin to comm INFO log. Implements #3766 --- src/octoprint/util/comm.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index b2a952192..429993666 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -1368,6 +1368,15 @@ class MachineCom(object): if tags is None: tags = set() + if "source:plugin" in tags: + for tag in tags: + if tag.startswith("plugin:"): + self._logger.info( + "Starting job on behalf of plugin {}".format(tag[7:]) + ) + elif "source:api" in tags: + self._logger.info("Starting job on behalf of user {}".format(user)) + try: with self._jobLock: self._consecutive_not_sd_printing = 0 @@ -1598,6 +1607,9 @@ class MachineCom(object): tags=None, external_sd=False, ): + if tags is None: + tags = set() + if not self.isOperational(): return @@ -1605,14 +1617,20 @@ class MachineCom(object): # we aren't even printing, nothing to cancel... return + if "source:plugin" in tags: + for tag in tags: + if tag.startswith("plugin:"): + self._logger.info( + "Cancelling job on behalf of plugin {}".format(tag[7:]) + ) + elif "source:api" in tags: + self._logger.info("Cancelling job on behalf of user {}".format(user)) + if self.isStreaming(): # we are streaming, we handle cancelling that differently... self.cancelFileTransfer() return - if tags is None: - tags = set() - def _on_M400_sent(): # we don't call on_print_job_cancelled on our callback here # because we do this only after our M114 has been answered @@ -1736,6 +1754,15 @@ class MachineCom(object): if tags is None: tags = set() + if "source:plugin" in tags: + for tag in tags: + if tag.startswith("plugin:"): + self._logger.info( + "Pausing/resuming job on behalf of plugin {}".format(tag[7:]) + ) + elif user: + self._logger.info("Pausing/resuming job on behalf of user {}".format(user)) + valid_paused_states = (self.STATE_PAUSED, self.STATE_PAUSING) valid_running_states = ( self.STATE_PRINTING,