Compare commits

...
Author SHA1 Message Date
aclist 5423d9ad56 chore: add strings file 2026-11-21 20:47:28 +09:00
aclist 1aed045149 feat: export debug log to a named file 2026-11-21 20:45:28 +09:00
6 changed files with 53 additions and 21 deletions

No files matched your search

+4 -2
View File
@@ -207,7 +207,8 @@ class RowType(Enum):
CHANGELOG = RowMeta(rows.changelog_label, rows.changelog_status)
SHOW_LOG = RowMeta(rows.log_label, rows.log_status)
SEPARATOR = RowMeta(rows.separator_label, rows.separator_status)
DUMP_LOG = RowMeta(rows.system_log_label, rows.system_log_status)
DUMP_DIAGNOSTIC = RowMeta(rows.system_log_label, rows.system_log_status)
DUMP_DEBUG = RowMeta(rows.debug_log_label, rows.debug_log_status)
DOCS = RowMeta(rows.docs_label, rows.docs_status)
DOCS_FALLBACK = RowMeta(rows.docs_fallback_label, rows.docs_fallback_status)
BUGS = RowMeta(rows.bugs_label, rows.bugs_status)
@@ -302,7 +303,8 @@ class ButtonType(Enum):
HELP_MENU_ROWS = (
RowType.CHANGELOG,
RowType.SHOW_LOG,
RowType.DUMP_LOG,
RowType.DUMP_DIAGNOSTIC,
RowType.DUMP_DEBUG,
RowType.SEPARATOR,
RowType.DOCS,
RowType.DOCS_FALLBACK,
+18 -3
View File
@@ -2,6 +2,7 @@ import gi
import logging
import threading
from pathlib import Path
from typing import Any, TYPE_CHECKING, Union
from dzgui.config.userprefs import UserPrefs
@@ -23,7 +24,7 @@ from dzgui.model.servers import ServerModelManager
from dzgui.util.diag import write_diagnostic
from dzgui.util.format import format_exception, format_player_count
from dzgui.util.open_links import open_user_workshop, open_workshop_page
from dzgui.views.dialogs.filepicker import FilePicker
from dzgui.views.dialogs.filepicker import DebugLogPicker, DiagnosticLogPicker
from dzgui.views.dialogs.generic import ExceptionDialog
gi.require_version("Gtk", "3.0")
@@ -297,9 +298,10 @@ class Controller(GObject.GObject):
return self.get_active_treeview().get_filter_man()
def dump_diagnostics(self) -> None:
picker = FilePicker(self.mediator.window)
picker = DiagnosticLogPicker(self.mediator.window)
file = picker.pick_file()
if file is not None:
if file is None:
return
try:
write_diagnostic(self.prefs.paths.config, file)
except Exception as e:
@@ -307,6 +309,19 @@ class Controller(GObject.GObject):
dialog.show_all()
dialog.run() # type: ignore[no-untyped-call]
def dump_log(self) -> None:
picker = DebugLogPicker(self.mediator.window)
file = picker.pick_file()
if file is None:
return
try:
log = self.prefs.paths.debug.read_text()
Path(file).write_text(log)
except Exception as e:
dialog = ExceptionDialog(self, str(e))
dialog.show_all()
dialog.run() # type: ignore[no-untyped-call]
def update_steam_api_key(self, text: str) -> None:
self.config_man.update_steam_api_key(text)
+2
View File
@@ -0,0 +1,2 @@
debug_picker_title = "Save the debug log to a file"
diagnostic_picker_title = "Save system diagnostics to a file"
+4 -1
View File
@@ -7,9 +7,12 @@ log_status = "Read the DZGUI log generated since startup"
separator_label = "SEPARATOR"
separator_status = ""
system_log_label = "Output system info to log file"
system_log_label = "Output system info to a file"
system_log_status = "Dump diagnostic data for troubleshooting"
debug_log_label = "Output debug log to a file"
debug_log_status = "Dump a summary of errors/events since DZGUI started"
docs_label = "Documentation/help files (GitHub) ⧉"
docs_status = "Open the DZGUI documentation in a browser"
+15 -4
View File
@@ -1,6 +1,7 @@
from pathlib import Path
from dzgui.util.strings import picker
from dzgui.const.constants import DEBUG_LOG, SYSTEM_LOG
from dzgui.strings.filepickers import diagnostic_picker_title, debug_picker_title
import gi
@@ -9,9 +10,9 @@ from gi.repository import Gtk
class FilePicker(Gtk.FileChooserDialog):
def __init__(self, parent: Gtk.Window) -> None:
def __init__(self, parent: Gtk.Window, title: str, placeholder: str) -> None:
super().__init__(
title=picker.title,
title=title,
action=Gtk.FileChooserAction.SAVE,
transient_for=parent,
resizable=True,
@@ -20,7 +21,7 @@ class FilePicker(Gtk.FileChooserDialog):
self.add_buttons("_Save", Gtk.ResponseType.OK) # type: ignore[no-untyped-call]
self.set_default_response(Gtk.ResponseType.OK)
self.set_current_name(picker.placeholder)
self.set_current_name(placeholder)
def pick_file(self) -> Path | None:
res = self.run() # type: ignore[no-untyped-call]
@@ -35,6 +36,16 @@ class FilePicker(Gtk.FileChooserDialog):
return None
class DiagnosticLogPicker(FilePicker):
def __init__(self, parent: Gtk.Window) -> None:
super().__init__(parent, diagnostic_picker_title, SYSTEM_LOG)
class DebugLogPicker(FilePicker):
def __init__(self, parent: Gtk.Window) -> None:
super().__init__(parent, debug_picker_title, DEBUG_LOG)
class FolderPicker(Gtk.FileChooserDialog):
def __init__(self, parent: Gtk.Window, title: str) -> None:
super().__init__(
+10 -11
View File
@@ -56,18 +56,17 @@ class MenuTreeView(TreeView):
self.controller.populate_log()
case RowType.CHANGELOG:
self.controller.open_page(NotebookPage.CHANGELOG)
case RowType.DUMP_LOG:
case RowType.DUMP_DIAGNOSTIC:
self.controller.dump_diagnostics()
pass
docs = [
RowType.DOCS,
RowType.DOCS_FALLBACK,
RowType.BUGS,
RowType.FORUM,
RowType.SPONSOR,
]
if row_type in docs:
case RowType.DUMP_DEBUG:
self.controller.dump_log()
case (
RowType.DOCS
| RowType.DOCS_FALLBACK
| RowType.BUGS
| RowType.FORUM
| RowType.SPONSOR
):
open_link_by_rowtype(row_type)
def get_row_enum(self) -> str: