Skip to content

Commit

Permalink
Merge pull request #297 from szobov/log-exceptions-with-tracebacks
Browse files Browse the repository at this point in the history
Refactoring: Logging in more friendly way
  • Loading branch information
giloser authored Oct 10, 2020
2 parents 3776c50 + 4f8f92e commit fab3622
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions octoprint_telegram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def loop(self):
raise exit
#wooooops. can't handle the message
except Exception as ex:
self._logger.error("Exception caught! " + str(ex))
self._logger.exception("Exception caught! " + str(ex))
self.set_status(gettext("Connected as %(username)s.", username=self.username), ok=True)
# we had first contact after octoprint startup
# so lets send startup message
Expand Down Expand Up @@ -866,7 +866,7 @@ def on_settings_migrate(self, target, current=None):
try:
self._settings.save()
except Exception as ex:
self._logger.error("MIGRATED Save failed - " + str(ex))
self._logger.exception("MIGRATED Save failed - " + str(ex))
self._logger.debug("MIGRATED Saved")


Expand Down Expand Up @@ -1158,9 +1158,9 @@ def _send_msg(self, message="", with_image=False,with_gif=False,responses=None,
self.send_file(chatID, ret,"")
sendOneInLoop = True
except Exception as ex:
self._logger.error("Exception loop multicam URL to create gif: "+ str(ex) )
self._logger.exception("Exception loop multicam URL to create gif: "+ str(ex) )
except Exception as ex:
self._logger.error("Exception occured on getting multicam options: "+ str(ex) )
self._logger.exception("Exception occured on getting multicam options: "+ str(ex) )
else:
ret = self.create_gif_new(chatID,0,0)

Expand Down Expand Up @@ -1249,11 +1249,11 @@ def _send_msg(self, message="", with_image=False,with_gif=False,responses=None,
self._logger.debug("url is the same as the one from octoprint " )

except Exception as ex:
self._logger.error("Exception loop multicam URL to create image: "+ str(ex) )
self._logger.exception("Exception loop multicam URL to create image: "+ str(ex) )
except Exception as ex:
self._logger.error("Exception occured on getting multicam options: "+ str(ex) )
self._logger.exception("Exception occured on getting multicam options: "+ str(ex) )
except Exception as ex:
self._logger.error("Exception occured on getting multicam plugin: "+ str(ex) )
self._logger.exception("Exception occured on getting multicam plugin: "+ str(ex) )

if r is not None and inline:
r.raise_for_status()
Expand Down Expand Up @@ -1348,7 +1348,7 @@ def get_usrPic(self,chat_id, file_id=""):
self._logger.debug("Saved Photo "+ str(chat_id))

except Exception as ex:
self._logger.error("Can't load UserImage: " + str(ex))
self._logger.exception("Can't load UserImage: " + str(ex))

def test_token(self, token=None):
if not self.send_messages:
Expand Down Expand Up @@ -1414,7 +1414,7 @@ def take_image(self,snapshot_url=""):
r = requests.get(snapshot_url,timeout=10)
data = r.content
except Exception as e:
self._logger.error("TimeOut Exception: " + str(e))
self._logger.exception("TimeOut Exception: " + str(e))
return None
flipH = self._settings.global_get(["webcam", "flipH"])
flipV = self._settings.global_get(["webcam", "flipV"])
Expand Down Expand Up @@ -1460,7 +1460,7 @@ def calculate_ETA(self,printTime = 0):
else:
strtime = " " + format_date(finish_time,"EEE d")
except Exception as ex:
self._logger.error("An Exception in get final time : " + str(ex) )
self._logger.exception("An Exception in get final time : " + str(ex) )

return strtime + strdate

Expand Down

0 comments on commit fab3622

Please sign in to comment.