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:
parent
644575415e
commit
a93c0c8d94
@ -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
|
||||
|
@ -3,6 +3,17 @@
|
||||
{% block title %}{{ config.APP_NAME }}{% endblock %}
|
||||
|
||||
{% block init_script %}
|
||||
window.hookConsole = function(callback) {
|
||||
for (const method of ['log', 'error']) {
|
||||
const nativeMethod = window.console[method];
|
||||
window.console[method] = function () {
|
||||
nativeMethod.apply(this, arguments);
|
||||
setTimeout(()=>{
|
||||
callback(method, arguments);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
require(
|
||||
['sources/generated/app.bundle', 'sources/generated/codemirror', 'sources/generated/browser_nodes'],
|
||||
|
@ -176,7 +176,7 @@ export class MenuItem {
|
||||
* Checks this menu enable/disable state based on the selection.
|
||||
*/
|
||||
disabled(node, item) {
|
||||
if (this.enable == undefined) {
|
||||
if (this.enable == undefined || !node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user