reduce logs for non-debug runtime

This commit is contained in:
kulikov0 committed 2026-07-25 09:15:10 +02:00
1 parent 5103d87211
commit d66be97922
39 files changed
+182 -31

No files matched your search

+1
View File
@@ -59,6 +59,7 @@ export enum IPC {
START_BOT = 'start-bot',
STOP_BOT = 'stop-bot',
SET_UPSTREAM_PROXY = 'set-upstream-proxy',
SET_DEBUG_LOGGING = 'set-debug-logging',
CLEAR_COOKIES = 'clear-cookies',
EXPORT_COOKIES_ZIP = 'export-cookies-zip',
RELAY_LOG = 'relay-log',
+4
View File
@@ -90,6 +90,10 @@ export function registerIpcHandlers(tabManager: TabManager): void {
tabManager.setUpstreamProxy(proxy);
});
ipcMain.handle(IPC.SET_DEBUG_LOGGING, (_e, enabled: boolean) => {
tabManager.setDebugLogging(enabled);
});
ipcMain.handle(IPC.CLEAR_COOKIES, (_e, platform: string) => {
return tabManager.clearPlatformCookies(platform as Platform);
});
+7
View File
@@ -53,6 +53,7 @@ export class TabManager {
private headlessDionPath: string;
private hooksDir: string;
private upstreamProxy: UpstreamProxy = { socks: '', user: '', pass: '' };
private debugLogging = false;
constructor() {
this.relayPath = resolveResourcePath(
@@ -223,6 +224,10 @@ export class TabManager {
};
}
setDebugLogging(enabled: boolean): void {
this.debugLogging = enabled;
}
private appendUpstreamArgs(args: string[]): void {
if (!this.upstreamProxy.socks) return;
args.push('--upstream-socks', this.upstreamProxy.socks);
@@ -241,6 +246,7 @@ export class TabManager {
}
const relayArgs = ['--mode', relayMode, '--ws-port', String(port)];
this.appendUpstreamArgs(relayArgs);
if (this.debugLogging) relayArgs.push('--debug');
const proc = spawn(this.relayPath, relayArgs, {
stdio: ['ignore', 'pipe', 'pipe'],
});
@@ -371,6 +377,7 @@ export class TabManager {
if (flag) spawnArgs.push(flag, joinTarget);
}
this.appendUpstreamArgs(spawnArgs);
if (this.debugLogging) spawnArgs.push('--debug');
const proc = spawn(config.binaryPath, spawnArgs, {
stdio: ['ignore', 'pipe', 'pipe'],
});
+3
View File
@@ -26,6 +26,9 @@ import { IPC } from '../constants';
setUpstreamProxy(proxy: any) {
return ipcRenderer.invoke(IPC.SET_UPSTREAM_PROXY, proxy);
},
setDebugLogging(enabled: boolean) {
return ipcRenderer.invoke(IPC.SET_DEBUG_LOGGING, enabled);
},
clearCookies(platform: string) {
return ipcRenderer.invoke(IPC.CLEAR_COOKIES, platform);
},
+3
View File
@@ -89,6 +89,8 @@ function bindSettingsEvents(): void {
tm.upstreamProxy.user = (document.getElementById('upstreamUser') as HTMLInputElement).value.trim();
tm.upstreamProxy.pass = (document.getElementById('upstreamPass') as HTMLInputElement).value.trim();
tm.saveUpstreamProxy();
tm.debugLogging = (document.getElementById('debugLogging') as HTMLInputElement).checked;
tm.saveDebugLogging();
closeSettings();
});
document.querySelectorAll('.btn-clear-cookies').forEach((btn) => {
@@ -174,6 +176,7 @@ function openSettings(): void {
(document.getElementById('upstreamSocks') as HTMLInputElement).value = tm.upstreamProxy.socks;
(document.getElementById('upstreamUser') as HTMLInputElement).value = tm.upstreamProxy.user;
(document.getElementById('upstreamPass') as HTMLInputElement).value = tm.upstreamProxy.pass;
(document.getElementById('debugLogging') as HTMLInputElement).checked = tm.debugLogging;
document.getElementById('clearCookiesStatus')!.textContent = '';
}
+7
View File
@@ -20,6 +20,7 @@ export class RendererTabManager {
botRunning = false;
botSettings: BotSettings;
upstreamProxy: UpstreamProxy;
debugLogging: boolean;
private onRender: () => void;
constructor(onRender: () => void) {
@@ -32,6 +33,7 @@ export class RendererTabManager {
this.upstreamProxy = savedProxy
? JSON.parse(savedProxy)
: { socks: '', user: '', pass: '' };
this.debugLogging = localStorage.getItem('debugLogging') === 'true';
}
createTab(): string {
@@ -247,6 +249,11 @@ export class RendererTabManager {
window.bridge.setUpstreamProxy(this.upstreamProxy);
}
saveDebugLogging(): void {
localStorage.setItem('debugLogging', String(this.debugLogging));
window.bridge.setDebugLogging(this.debugLogging);
}
toggleBot(): void {
if (!this.botSettings.token || !this.botSettings.groupId) return;
this.botRunning = !this.botRunning;
+1
View File
@@ -151,6 +151,7 @@ export interface Bridge {
startBot(settings: BotSettings): Promise<void>;
stopBot(): Promise<void>;
setUpstreamProxy(proxy: UpstreamProxy): Promise<void>;
setDebugLogging(enabled: boolean): Promise<void>;
clearCookies(platform: string): Promise<number>;
onCreateBotTab(cb: (data: BotTabData) => void): void;
getCallCreatorCode(scriptFile: string): Promise<string>;