mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
ELECTRON-907: add logging for browser window and web contents
This commit is contained in:
@@ -31,7 +31,7 @@ function gatherMemory() {
|
|||||||
' peakWorkingSetSize: ' + memory.peakWorkingSetSize +
|
' peakWorkingSetSize: ' + memory.peakWorkingSetSize +
|
||||||
' privatesBytes: ' + memory.privatesBytes +
|
' privatesBytes: ' + memory.privatesBytes +
|
||||||
' sharedBytes: ' + memory.sharedBytes;
|
' sharedBytes: ' + memory.sharedBytes;
|
||||||
log.send(logLevels.INFO, details);
|
log.send(logLevels.INFO, `Current Memory Stats -> ${details}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -56,14 +56,14 @@ const logAppEvents = () => {
|
|||||||
|
|
||||||
const events = [
|
const events = [
|
||||||
'will-finish-launching', 'ready', 'window-all-closed', 'before-quit', 'will-quit', 'quit',
|
'will-finish-launching', 'ready', 'window-all-closed', 'before-quit', 'will-quit', 'quit',
|
||||||
'open-file', 'open-url', 'activate', 'browser-window-blur', 'browser-window-focus',
|
'open-file', 'open-url', 'activate',
|
||||||
'browser-window-created', 'web-contents-created', 'certificate-error', 'login', 'gpu-process-crashed',
|
'browser-window-created', 'web-contents-created', 'certificate-error', 'login', 'gpu-process-crashed',
|
||||||
'accessibility-support-changed', 'session-created', 'second-instance'
|
'accessibility-support-changed', 'session-created', 'second-instance'
|
||||||
];
|
];
|
||||||
|
|
||||||
events.forEach((appEvent) => {
|
events.forEach((appEvent) => {
|
||||||
app.on(appEvent, () => {
|
app.on(appEvent, () => {
|
||||||
log.send(logLevels.INFO, `Event Occurred: ${appEvent}`)
|
log.send(logLevels.INFO, `App Event Occurred: ${appEvent}`)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -196,6 +196,7 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
|
|||||||
|
|
||||||
mainWindow = new BrowserWindow(newWinOpts);
|
mainWindow = new BrowserWindow(newWinOpts);
|
||||||
mainWindow.winName = 'main';
|
mainWindow.winName = 'main';
|
||||||
|
logBrowserWindowEvents(mainWindow, mainWindow.winName);
|
||||||
|
|
||||||
let throttledMainWinBoundsChange = throttle(1000, saveMainWinBounds);
|
let throttledMainWinBoundsChange = throttle(1000, saveMainWinBounds);
|
||||||
mainWindow.on('move', throttledMainWinBoundsChange);
|
mainWindow.on('move', throttledMainWinBoundsChange);
|
||||||
@@ -456,7 +457,7 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
|
|||||||
let browserWin = BrowserWindow.fromWebContents(childWebContents);
|
let browserWin = BrowserWindow.fromWebContents(childWebContents);
|
||||||
|
|
||||||
if (browserWin) {
|
if (browserWin) {
|
||||||
log.send(logLevels.INFO, 'loaded pop-out window url: ' + newWinParsedUrl);
|
log.send(logLevels.INFO, `loaded pop-out window url: ${JSON.stringify(newWinParsedUrl)}`);
|
||||||
|
|
||||||
browserWin.webContents.send('on-page-load');
|
browserWin.webContents.send('on-page-load');
|
||||||
// applies styles required for snack bar
|
// applies styles required for snack bar
|
||||||
@@ -467,6 +468,7 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
|
|||||||
|
|
||||||
browserWin.winName = frameName;
|
browserWin.winName = frameName;
|
||||||
browserWin.setAlwaysOnTop(alwaysOnTop);
|
browserWin.setAlwaysOnTop(alwaysOnTop);
|
||||||
|
logBrowserWindowEvents(browserWin, browserWin.winName);
|
||||||
|
|
||||||
let handleChildWindowCrashEvent = (e) => {
|
let handleChildWindowCrashEvent = (e) => {
|
||||||
const options = {
|
const options = {
|
||||||
@@ -1187,6 +1189,44 @@ function popupMenu() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const logBrowserWindowEvents = (browserWindow, windowName) => {
|
||||||
|
|
||||||
|
const events = [
|
||||||
|
'page-title-updated', 'close', 'closed', 'session-end', 'unresponsive', 'responsive', 'blur', 'focus',
|
||||||
|
'show', 'hide', 'ready-to-show', 'maximize', 'unmaximize', 'minimize', 'restore', 'resize', 'move', 'moved',
|
||||||
|
'enter-full-screen', 'leave-full-screen', 'enter-html-full-screen', 'leave-html-full-screen', 'app-command'
|
||||||
|
];
|
||||||
|
|
||||||
|
events.forEach((browserWindowEvent) => {
|
||||||
|
browserWindow.on(browserWindowEvent, () => {
|
||||||
|
log.send(logLevels.INFO, `Browser Window Event Occurred for window (${windowName}) -> ${browserWindowEvent}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
logBrowserWindowWebContentEvents(browserWindow.webContents, windowName);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const logBrowserWindowWebContentEvents = (webContent, windowName) => {
|
||||||
|
|
||||||
|
const events = [
|
||||||
|
'did-finish-load', 'did-fail-load', 'did-frame-finish-load', 'did-start-loading', 'did-stop-loading',
|
||||||
|
'dom-ready', 'page-favicon-updated', 'new-window', 'will-navigate', 'did-start-navigation', 'did-navigate',
|
||||||
|
'did-frame-navigate', 'did-navigate-in-page', 'will-prevent-unload', 'crashed', 'unresponsive', 'responsive',
|
||||||
|
'plugin-crashed', 'destroyed', 'before-input-event', 'devtools-opened', 'devtools-closed', 'devtools-focused',
|
||||||
|
'certificate-error', 'select-client-certificate', 'login', 'found-in-page', 'media-started-playing',
|
||||||
|
'media-paused', 'did-change-theme-color', 'update-target-url', 'cursor-changed', 'context-menu',
|
||||||
|
'select-bluetooth-device', 'paint', 'devtools-reload-page', 'will-attach-webview', 'did-attach-webview',
|
||||||
|
'console-message'
|
||||||
|
];
|
||||||
|
|
||||||
|
events.forEach((webContentEvent) => {
|
||||||
|
webContent.on(webContentEvent, () => {
|
||||||
|
log.send(logLevels.INFO, `Web Content Event Occurred for window (${windowName}) -> ${webContentEvent}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
createMainWindow: createMainWindow,
|
createMainWindow: createMainWindow,
|
||||||
|
|||||||
Reference in New Issue
Block a user