Redirect pgAdmin main window console logs to NW.js server logs.

This commit is contained in:
Aditya Toshniwal
2023-04-06 15:16:14 +05:30
committed by GitHub
parent 644575415e
commit a93c0c8d94
4 changed files with 30 additions and 1 deletions

View File

@@ -424,6 +424,18 @@ let ConfigureStore = {
},
};
function parseConsoleArgs(_method, args) {
const retData = Array.from(args).map(arg => {
try {
if(arg.stack) return arg.stack;
return JSON.stringify(arg);
} catch (e) {
return arg
}
});
return retData?.join(' ');
}
module.exports = {
readServerLog: readServerLog,
@@ -444,4 +456,5 @@ module.exports = {
unregisterZoomEvents: unregisterZoomEvents,
setZoomLevelForAllWindows: setZoomLevelForAllWindows,
ConfigureStore: ConfigureStore,
parseConsoleArgs: parseConsoleArgs,
};

View File

@@ -11,6 +11,7 @@ const fs = require('fs');
const path = require('path');
const misc = require('../js/misc.js');
const spawn = require('child_process').spawn;
const {EOL} = require('os');
let pgadminServerProcess = null;
let startPageUrl = null;
@@ -249,6 +250,10 @@ function launchPgAdminWindow() {
* nothing but a splash screen. We will have to make it null,
* so that open in new browser tab will work.
*/
pgadminWindow.window.hookConsole((method, args)=>{
misc.writeServerLog(
`--------------[UI ${method}]---------------${EOL}${misc.parseConsoleArgs(method, args)}${EOL}------------[UI End]----------------`);
});
pgadminWindow.window.opener = null;
// Show new window