Core - Last Errors Btn

This commit is contained in:
Rick Lan
2025-04-08 17:14:19 +08:00
parent b981d44eba
commit cab81c497e
3 changed files with 21 additions and 0 deletions

View File

@@ -120,4 +120,5 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
{"UpdaterTargetBranch", CLEAR_ON_MANAGER_START},
{"UpdaterLastFetchTime", PERSISTENT},
{"Version", PERSISTENT},
{"dp_device_last_log", CLEAR_ON_ONROAD_TRANSITION},
};

View File

@@ -45,6 +45,21 @@ DeveloperPanel::DeveloperPanel(SettingsWindow *parent) : ListWidget(parent) {
// Toggles should be not available to change in onroad state
QObject::connect(uiState(), &UIState::offroadTransition, this, &DeveloperPanel::updateToggles);
// error logs
QPushButton* error_log_btn = new QPushButton(QObject::tr("Show Last Errors"));
error_log_btn->setObjectName("error_log_btn");
error_log_btn->setStyleSheet(R"(
#error_log_btn { height: 120px; border-radius: 15px; background-color: #393939; }
#error_log_btn:pressed { background-color: #4a4a4a; }
)");
addItem(error_log_btn);
QObject::connect(error_log_btn, &QPushButton::clicked, [=]() {
ConfirmationDialog::rich(QString::fromStdString(params.get("dp_device_last_log")), parent);
});
}
void DeveloperPanel::updateToggles(bool _offroad) {

View File

@@ -26,11 +26,16 @@ def report_tombstone(fn: str, message: str, contents: str) -> None:
sentry_sdk.capture_message(message=message)
sentry_sdk.flush()
def save_exception(exc_text):
log = "\n".join(exc_text.splitlines()) + "\n"
Params().put("dp_device_last_log", log)
def capture_exception(*args, **kwargs) -> None:
cloudlog.error("crash", exc_info=kwargs.get('exc_info', 1))
try:
import traceback
save_exception(traceback.format_exc())
sentry_sdk.capture_exception(*args, **kwargs)
sentry_sdk.flush() # https://github.com/getsentry/sentry-python/issues/291
except Exception: