feat(dashboard): export logs from the console and settings pages (#10… · AstrBotDevs/AstrBot@f52fe19 · GitHub
Skip to content

Commit f52fe19

Browse files
feat(dashboard): export logs from the console and settings pages (#10418)
* feat(dashboard): export logs from the console and settings pages Add GET /api/v1/logs/export, which packs the log files and the in-memory logs into a zip archive. The files come from StorageCleaner, so log and trace log paths configured outside data/logs are included too, and the in-memory cache is split into memory/logs.txt and memory/traces.jsonl. Add an Export Logs button to the console page and to the log and cache cleanup panel in Settings. Closes #10407 * feat(dashboard): skip non-regular files and add a manifest to log exports Only pack regular files, so a symlink in a log directory cannot pull in a file from elsewhere and a FIFO cannot block the export. Skipped files and files that disappear while packing are listed in manifest.json with the reason, together with the AstrBot version and the in-memory log counts. Also keep same-named log files from different directories apart, and remove archives left behind by cancelled downloads. * fix(dashboard): harden log export against swapped files and disk use Open each log file without following symlinks or blocking on FIFOs and check the opened descriptor, so a file swapped after the lstat() check cannot get into the archive. Run one export at a time and check the free temp space before packing. Reserve the generated archive entries and dedupe every file name, move the temp directory setup into the handled block, and say in the tooltip and docs that without file logging the archive mostly has in-memory logs, since older log files on disk are still included. * feat(dashboard): unify diagnostic and log export --------- Co-authored-by: advent259141 <2968474907@qq.com>
1 parent f2404c1 commit f52fe19

20 files changed

Lines changed: 1413 additions & 17 deletions

File tree

‎astrbot/core/utils/storage_cleaner.py‎

Lines changed: 24 additions & 6 deletions

‎astrbot/dashboard/api/app.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def create_dashboard_asgi_app(
126126
files=FileService(),
127127
knowledge_bases=KnowledgeBaseService(core_lifecycle),
128128
live_chat=LiveChatService(db, core_lifecycle),
129-
logs=LogService(log_broker, core_lifecycle.astrbot_config),
129+
logs=LogService(log_broker, core_lifecycle.astrbot_config, core=core_lifecycle),
130130
bots=BotConfigService(core_lifecycle),
131131
platforms=PlatformService(core_lifecycle),
132132
providers=ProviderConfigService(core_lifecycle),

‎astrbot/dashboard/api/logs.py‎

Lines changed: 24 additions & 1 deletion

0 commit comments

Comments
 (0)