mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Redirect pgAdmin main window console logs to NW.js server logs.
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user