mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 03:07:53 -06:00
Add sentry logger to display breadcrumbs
This commit is contained in:
parent
23057f786f
commit
6c8fddc765
4 changed files with 80 additions and 0 deletions
43
plugins/SentryLogger/SentryLogger.py
Normal file
43
plugins/SentryLogger/SentryLogger.py
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# Copyright (c) 2019 Ultimaker B.V.
|
||||||
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
from UM.Logger import LogOutput
|
||||||
|
from typing import Set
|
||||||
|
from sentry_sdk import add_breadcrumb
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
|
class SentryLogger(LogOutput):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__()
|
||||||
|
self._show_once = set() # type: Set[str]
|
||||||
|
|
||||||
|
## Log the message to the sentry hub as a breadcrumb
|
||||||
|
# \param log_type "e" (error), "i"(info), "d"(debug), "w"(warning) or "c"(critical) (can postfix with "_once")
|
||||||
|
# \param message String containing message to be logged
|
||||||
|
def log(self, log_type: str, message: str) -> None:
|
||||||
|
level = self._translateLogType(log_type)
|
||||||
|
if level is None:
|
||||||
|
if message not in self._show_once:
|
||||||
|
level = self._translateLogType(log_type[0])
|
||||||
|
if level is not None:
|
||||||
|
self._show_once.add(message)
|
||||||
|
add_breadcrumb(level=level, message=message)
|
||||||
|
else:
|
||||||
|
add_breadcrumb(level=level, message=message)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _translateLogType(log_type: str) -> Optional[str]:
|
||||||
|
level = None
|
||||||
|
if log_type == "w":
|
||||||
|
level = "warning"
|
||||||
|
elif log_type == "i":
|
||||||
|
level = "info"
|
||||||
|
elif log_type == "c":
|
||||||
|
level = "fatal"
|
||||||
|
elif log_type == "e":
|
||||||
|
level = "error"
|
||||||
|
elif log_type == "d":
|
||||||
|
level = "debug"
|
||||||
|
|
||||||
|
return level
|
12
plugins/SentryLogger/__init__.py
Normal file
12
plugins/SentryLogger/__init__.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# Copyright (c) 2019 Ultimaker B.V.
|
||||||
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
from . import SentryLogger
|
||||||
|
|
||||||
|
|
||||||
|
def getMetaData():
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
def register(app):
|
||||||
|
return { "logger": SentryLogger.SentryLogger() }
|
8
plugins/SentryLogger/plugin.json
Normal file
8
plugins/SentryLogger/plugin.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "Sentry Logger",
|
||||||
|
"author": "Ultimaker B.V.",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Logs certain events so that they can be used by the crash reporter",
|
||||||
|
"api": "7.0",
|
||||||
|
"i18n-catalog": "cura"
|
||||||
|
}
|
|
@ -407,6 +407,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"SentryLogger": {
|
||||||
|
"package_info": {
|
||||||
|
"package_id": "SentryLogger",
|
||||||
|
"package_type": "plugin",
|
||||||
|
"display_name": "Sentry Logger",
|
||||||
|
"description": "Logs certain events so that they can be used by the crash reporter",
|
||||||
|
"package_version": "1.0.0",
|
||||||
|
"sdk_version": "7.0.0",
|
||||||
|
"website": "https://ultimaker.com",
|
||||||
|
"author": {
|
||||||
|
"author_id": "UltimakerPackages",
|
||||||
|
"display_name": "Ultimaker B.V.",
|
||||||
|
"email": "plugins@ultimaker.com",
|
||||||
|
"website": "https://ultimaker.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"SimulationView": {
|
"SimulationView": {
|
||||||
"package_info": {
|
"package_info": {
|
||||||
"package_id": "SimulationView",
|
"package_id": "SimulationView",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue