Feat : Log recorder
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { execFile, spawn } from 'node:child_process';
|
||||
import { promisify } from 'node:util';
|
||||
import type { BrowserSettings } from '@stream-control/shared';
|
||||
import type { AgentEvent, BrowserSettings } from '@stream-control/shared';
|
||||
|
||||
const run = promisify(execFile);
|
||||
|
||||
export interface BrowserLog {
|
||||
(level: 'info' | 'warn' | 'error', message: string): void;
|
||||
(level: 'info' | 'warn' | 'error', message: string, event?: AgentEvent): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ export async function openUrl(
|
||||
const target = assertWebUrl(url);
|
||||
const args = [...settings.args, target];
|
||||
|
||||
log('info', `Ouverture de ${target} (${settings.command})`);
|
||||
log('info', `Ouverture de ${target} (${settings.command})`, 'browser.opened');
|
||||
|
||||
const child = spawn(settings.command, args, {
|
||||
detached: true,
|
||||
@@ -103,7 +103,7 @@ export async function closeWindow(
|
||||
await run('xdotool', ['windowclose', id], { env, timeout: 5000 }).catch(() => undefined);
|
||||
}
|
||||
|
||||
log('info', `${ids.length} fenêtre(s) « ${match} » fermée(s)`);
|
||||
log('info', `${ids.length} fenêtre(s) « ${match} » fermée(s)`, 'browser.closed');
|
||||
return { closed: ids.length };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user