feat(launcher): add About log export shortcut and runtime logging toggle
Launcher release / release (push) Waiting to run
Launcher release / release (push) Waiting to run
Add a quick ZIP log export button to the About page (also bundling the latest embedded browser -browser.log while excluding player saves) and add a runtime logging toggle under Settings -> Diagnostics that controls launcher file logs, local server traffic logs, and wto_ws.log via log=0 in wto_ws.cfg. Update the v0.1.2 release note accordingly.
This commit is contained in:
1 parent
2d5e268083
commit
fb7d07f4f9
21 files changed
+230
-37
No files matched your search
@@ -69,6 +69,8 @@ export interface ServerOptions {
|
||||
readonly port: number;
|
||||
/** Start-up progress lines (static data extraction, game modes). */
|
||||
readonly report?: (line: string) => void;
|
||||
/** Whether to write traffic logs under `<dataFolder>/logs`; defaults to true. */
|
||||
readonly loggingEnabled?: boolean;
|
||||
}
|
||||
|
||||
export const LOOPBACK = '127.0.0.1';
|
||||
@@ -143,7 +145,7 @@ export async function startServer(options: ServerOptions): Promise<RunningServer
|
||||
})),
|
||||
new DownloadableContentService(),
|
||||
]);
|
||||
const log = new TrafficLog(options.dataFolder);
|
||||
const log = new TrafficLog(options.dataFolder, options.loggingEnabled ?? true);
|
||||
const listener = createPortListener(
|
||||
router,
|
||||
matchingRequests({
|
||||
|
||||
@@ -20,11 +20,19 @@ export interface MatchingLogEntry {
|
||||
|
||||
export class TrafficLog {
|
||||
readonly folder: string;
|
||||
readonly #enabled: boolean;
|
||||
readonly #linesPath: string;
|
||||
readonly #bodiesFolder: string;
|
||||
#sequence = 0;
|
||||
|
||||
constructor(dataFolder: string) {
|
||||
constructor(dataFolder: string, enabled = true) {
|
||||
this.#enabled = enabled;
|
||||
if (!enabled) {
|
||||
this.folder = '';
|
||||
this.#linesPath = '';
|
||||
this.#bodiesFolder = '';
|
||||
return;
|
||||
}
|
||||
this.folder = join(dataFolder, 'logs', new Date().toISOString().replace(/[:.]/g, '-'));
|
||||
this.#linesPath = join(this.folder, 'requests.jsonl');
|
||||
this.#bodiesFolder = join(this.folder, 'bodies');
|
||||
@@ -96,11 +104,12 @@ export class TrafficLog {
|
||||
}
|
||||
|
||||
#append(line: object): void {
|
||||
if (!this.#enabled) return;
|
||||
appendFileSync(this.#linesPath, JSON.stringify(line) + '\n');
|
||||
}
|
||||
|
||||
#writeBody(id: number, suffix: string, content: Uint8Array | string | undefined): string | null {
|
||||
if (content === undefined || byteLength(content) === 0) return null;
|
||||
if (!this.#enabled || content === undefined || byteLength(content) === 0) return null;
|
||||
const name = `${String(id).padStart(6, '0')}.${suffix}`;
|
||||
writeFileSync(join(this.#bodiesFolder, name), content);
|
||||
return name;
|
||||
|
||||
Reference in new issue
Block a user