Write the log of a game run to logs\totk.log next to totk.exe when stderr is not a file

A player who starts totk.exe from Explorer or a shortcut had no log to attach to a report: the log went only to stderr.
A game run whose stderr is not a file (a console or a pipe) now also writes logs\totk.log, keeps the four earlier
runs as totk.1.log to totk.4.log, and stops the file at 64 MiB. Runs whose stderr is a file (run_game.py, 2> file) and
the tool modes write no extra file. Lines from before the file opens (mem_init comes first so the CRT heap stays out of
the guest address space) wait in a static buffer.

Crash reports, fatal errors, IPC and SVC diagnostics, guest debug output and the boot: lines now go through
rt_logf / rt_log_raw, so they reach the file too. Open log folder in the menu opens the folder of the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-10-29 12:41:12 +03:00
1 parent f4619f7b45
commit c7b290f2b0
10 files changed
+146 -32

No files matched your search

+3 -3
View File
@@ -47,9 +47,9 @@ static uint64_t g_nhost;
void rt_fatal(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
fputs("FATAL: ", stderr);
vfprintf(stderr, fmt, ap);
fputc('\n', stderr);
rt_log_raw("FATAL: ", 7);
rt_vlogf(fmt, ap);
rt_log_raw("\n", 1);
va_end(ap);
fflush(stdout);
fflush(stderr);