mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 23:23:57 -06:00
Ensure that stored log lines are sent to sentry if they haven't already been logged
CURA-8760
This commit is contained in:
parent
e6830f0241
commit
3bfea5b970
3 changed files with 14 additions and 2 deletions
|
@ -12,10 +12,12 @@ import json
|
||||||
import locale
|
import locale
|
||||||
from typing import cast, Any
|
from typing import cast, Any
|
||||||
|
|
||||||
|
import sentry_sdk
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from sentry_sdk.hub import Hub
|
from sentry_sdk.hub import Hub
|
||||||
from sentry_sdk.utils import event_from_exception
|
from sentry_sdk.utils import event_from_exception
|
||||||
from sentry_sdk import configure_scope
|
from sentry_sdk import configure_scope, add_breadcrumb
|
||||||
with_sentry_sdk = True
|
with_sentry_sdk = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
with_sentry_sdk = False
|
with_sentry_sdk = False
|
||||||
|
@ -424,6 +426,13 @@ class CrashHandler:
|
||||||
if with_sentry_sdk:
|
if with_sentry_sdk:
|
||||||
try:
|
try:
|
||||||
hub = Hub.current
|
hub = Hub.current
|
||||||
|
if not Logger.getLoggers():
|
||||||
|
# No loggers have been loaded yet, so we don't have any breadcrumbs :(
|
||||||
|
# So add them manually so we at least have some info...
|
||||||
|
add_breadcrumb(level = "info", message = "SentryLogging was not initialised yet")
|
||||||
|
for log_type, line in Logger.getUnloggedLines():
|
||||||
|
add_breadcrumb(message=line)
|
||||||
|
|
||||||
event, hint = event_from_exception((self.exception_type, self.value, self.traceback))
|
event, hint = event_from_exception((self.exception_type, self.value, self.traceback))
|
||||||
hub.capture_event(event, hint=hint)
|
hub.capture_event(event, hint=hint)
|
||||||
hub.flush()
|
hub.flush()
|
||||||
|
|
|
@ -777,10 +777,14 @@ class CuraApplication(QtApplication):
|
||||||
lib_suffixes = {""}
|
lib_suffixes = {""}
|
||||||
for suffix in lib_suffixes:
|
for suffix in lib_suffixes:
|
||||||
self._plugin_registry.addPluginLocation(os.path.join(QtApplication.getInstallPrefix(), "lib" + suffix, "cura"))
|
self._plugin_registry.addPluginLocation(os.path.join(QtApplication.getInstallPrefix(), "lib" + suffix, "cura"))
|
||||||
|
|
||||||
if not hasattr(sys, "frozen"):
|
if not hasattr(sys, "frozen"):
|
||||||
self._plugin_registry.addPluginLocation(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "plugins"))
|
self._plugin_registry.addPluginLocation(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "plugins"))
|
||||||
self._plugin_registry.preloaded_plugins.append("ConsoleLogger")
|
self._plugin_registry.preloaded_plugins.append("ConsoleLogger")
|
||||||
|
|
||||||
|
# Since it's possible to get crashes in code before the sentrylogger is loaded, we want to start this plugin
|
||||||
|
# as quickly as possible, as we might get unsolvable crash reports without it.
|
||||||
|
self._plugin_registry.preloaded_plugins.append("SentryLogger")
|
||||||
self._plugin_registry.loadPlugins()
|
self._plugin_registry.loadPlugins()
|
||||||
|
|
||||||
if self.getBackend() is None:
|
if self.getBackend() is None:
|
||||||
|
|
|
@ -11,7 +11,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
class SentryLogger(LogOutput):
|
class SentryLogger(LogOutput):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue