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 = {
|
module.exports = {
|
||||||
readServerLog: readServerLog,
|
readServerLog: readServerLog,
|
||||||
@ -444,4 +456,5 @@ module.exports = {
|
|||||||
unregisterZoomEvents: unregisterZoomEvents,
|
unregisterZoomEvents: unregisterZoomEvents,
|
||||||
setZoomLevelForAllWindows: setZoomLevelForAllWindows,
|
setZoomLevelForAllWindows: setZoomLevelForAllWindows,
|
||||||
ConfigureStore: ConfigureStore,
|
ConfigureStore: ConfigureStore,
|
||||||
|
parseConsoleArgs: parseConsoleArgs,
|
||||||
};
|
};
|
||||||
|
@ -11,6 +11,7 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const misc = require('../js/misc.js');
|
const misc = require('../js/misc.js');
|
||||||
const spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
|
const {EOL} = require('os');
|
||||||
|
|
||||||
let pgadminServerProcess = null;
|
let pgadminServerProcess = null;
|
||||||
let startPageUrl = null;
|
let startPageUrl = null;
|
||||||
@ -249,6 +250,10 @@ function launchPgAdminWindow() {
|
|||||||
* nothing but a splash screen. We will have to make it null,
|
* nothing but a splash screen. We will have to make it null,
|
||||||
* so that open in new browser tab will work.
|
* 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;
|
pgadminWindow.window.opener = null;
|
||||||
|
|
||||||
// Show new window
|
// Show new window
|
||||||
|
@ -3,6 +3,17 @@
|
|||||||
{% block title %}{{ config.APP_NAME }}{% endblock %}
|
{% block title %}{{ config.APP_NAME }}{% endblock %}
|
||||||
|
|
||||||
{% block init_script %}
|
{% 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 {
|
try {
|
||||||
require(
|
require(
|
||||||
['sources/generated/app.bundle', 'sources/generated/codemirror', 'sources/generated/browser_nodes'],
|
['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.
|
* Checks this menu enable/disable state based on the selection.
|
||||||
*/
|
*/
|
||||||
disabled(node, item) {
|
disabled(node, item) {
|
||||||
if (this.enable == undefined) {
|
if (this.enable == undefined || !node) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user