mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
refactor: update logic to find webcontents that have send function
This commit is contained in:
@@ -4,7 +4,12 @@ export const ipcLogger = ({ content, cUid, level }: {content: string; cUid: stri
|
||||
if (level === 'error') {
|
||||
if (process.type !== undefined) {
|
||||
const contents = require('electron').webContents.getAllWebContents();
|
||||
const mainWindow = require('electron').webContents.fromId(1) ?? contents[0];
|
||||
let mainWindow = require('electron').webContents.fromId(1);
|
||||
contents.forEach(content => {
|
||||
if (content.send && mainWindow === undefined) {
|
||||
mainWindow = content;
|
||||
}
|
||||
});
|
||||
mainWindow.send('non-blocking-exception', { cUid, message: content, date: new Date() });
|
||||
}
|
||||
if (process.env.NODE_ENV === 'development' && process.type === 'browser') console.log(content);
|
||||
@@ -14,7 +19,12 @@ export const ipcLogger = ({ content, cUid, level }: {content: string; cUid: stri
|
||||
const escapedSql = content.replace(/(\/\*(.|[\r\n])*?\*\/)|(--(.*|[\r\n]))/gm, '').replace(/\s\s+/g, ' ');
|
||||
if (process.type !== undefined) {
|
||||
const contents = require('electron').webContents.getAllWebContents();
|
||||
const mainWindow = require('electron').webContents.fromId(1) ?? contents[0];
|
||||
let mainWindow = require('electron').webContents.fromId(1);
|
||||
contents.forEach(content => {
|
||||
if (content.send && mainWindow === undefined) {
|
||||
mainWindow = content;
|
||||
}
|
||||
});
|
||||
mainWindow.send('query-log', { cUid, sql: escapedSql, date: new Date() });
|
||||
}
|
||||
if (process.env.NODE_ENV === 'development' && process.type === 'browser') console.log(escapedSql);
|
||||
|
Reference in New Issue
Block a user