mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 14:03:57 +00:00
show logs from menu
This commit is contained in:
@@ -86,6 +86,9 @@ module.exports = ({ editMenu }) => [
|
|||||||
{ command: 'sql.generator', hideDisabled: true },
|
{ command: 'sql.generator', hideDisabled: true },
|
||||||
{ command: 'file.import', hideDisabled: true },
|
{ command: 'file.import', hideDisabled: true },
|
||||||
{ command: 'new.modelCompare', hideDisabled: true },
|
{ command: 'new.modelCompare', hideDisabled: true },
|
||||||
|
{ divider: true },
|
||||||
|
{ command: 'folder.showLogs', hideDisabled: true },
|
||||||
|
{ command: 'folder.showData', hideDisabled: true },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
10
package.json
10
package.json
@@ -10,15 +10,15 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start:api": "yarn workspace dbgate-api start | pino-pretty",
|
"start:api": "yarn workspace dbgate-api start | pino-pretty",
|
||||||
"start:api:json": "yarn workspace dbgate-api start",
|
"start:api:json": "yarn workspace dbgate-api start",
|
||||||
"start:app": "cd app && yarn start",
|
"start:app": "cd app && yarn start | pino-pretty",
|
||||||
"start:api:debug": "cross-env DEBUG=* yarn workspace dbgate-api start",
|
"start:api:debug": "cross-env DEBUG=* yarn workspace dbgate-api start",
|
||||||
"start:app:debug": "cd app && cross-env DEBUG=* yarn start",
|
"start:app:debug": "cd app && cross-env DEBUG=* yarn start",
|
||||||
"start:api:debug:ssh": "cross-env DEBUG=ssh yarn workspace dbgate-api start",
|
"start:api:debug:ssh": "cross-env DEBUG=ssh yarn workspace dbgate-api start",
|
||||||
"start:app:debug:ssh": "cd app && cross-env DEBUG=ssh yarn start",
|
"start:app:debug:ssh": "cd app && cross-env DEBUG=ssh yarn start",
|
||||||
"start:api:portal": "yarn workspace dbgate-api start:portal",
|
"start:api:portal": "yarn workspace dbgate-api start:portal | pino-pretty",
|
||||||
"start:api:singledb": "yarn workspace dbgate-api start:singledb",
|
"start:api:singledb": "yarn workspace dbgate-api start:singledb | pino-pretty",
|
||||||
"start:api:auth": "yarn workspace dbgate-api start:auth",
|
"start:api:auth": "yarn workspace dbgate-api start:auth | pino-pretty",
|
||||||
"start:api:dblogin": "yarn workspace dbgate-api start:dblogin",
|
"start:api:dblogin": "yarn workspace dbgate-api start:dblogin | pino-pretty",
|
||||||
"start:web": "yarn workspace dbgate-web dev",
|
"start:web": "yarn workspace dbgate-web dev",
|
||||||
"start:sqltree": "yarn workspace dbgate-sqltree start",
|
"start:sqltree": "yarn workspace dbgate-sqltree start",
|
||||||
"start:tools": "yarn workspace dbgate-tools start",
|
"start:tools": "yarn workspace dbgate-tools start",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const fs = require('fs-extra');
|
|||||||
const os = require('os');
|
const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const { datadir } = require('../utility/directories');
|
const { datadir, getLogsFilePath } = require('../utility/directories');
|
||||||
const { hasPermission, getLogins } = require('../utility/hasPermission');
|
const { hasPermission, getLogins } = require('../utility/hasPermission');
|
||||||
const socket = require('../utility/socket');
|
const socket = require('../utility/socket');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
@@ -48,6 +48,8 @@ module.exports = {
|
|||||||
oauthScope: process.env.OAUTH_SCOPE,
|
oauthScope: process.env.OAUTH_SCOPE,
|
||||||
oauthLogout: process.env.OAUTH_LOGOUT,
|
oauthLogout: process.env.OAUTH_LOGOUT,
|
||||||
isLoginForm: !!process.env.AD_URL || (!!logins && !process.env.BASIC_AUTH),
|
isLoginForm: !!process.env.AD_URL || (!!logins && !process.env.BASIC_AUTH),
|
||||||
|
logsFilePath: getLogsFilePath(),
|
||||||
|
connectionsFilePath: path.join(datadir(), 'connections.jsonl'),
|
||||||
...currentVersion,
|
...currentVersion,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const pinoms = require('pino-multi-stream');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { logsdir } = require('./utility/directories');
|
const { logsdir, setLogsFilePath } = require('./utility/directories');
|
||||||
|
|
||||||
if (processArgs.startProcess) {
|
if (processArgs.startProcess) {
|
||||||
setLoggerName(processArgs.startProcess.replace(/Process$/, ''));
|
setLoggerName(processArgs.startProcess.replace(/Process$/, ''));
|
||||||
@@ -17,13 +17,14 @@ if (processArgs.processDisplayName) {
|
|||||||
if (processArgs.listenApi) {
|
if (processArgs.listenApi) {
|
||||||
// configure logger
|
// configure logger
|
||||||
|
|
||||||
|
const logsFilePath = path.join(logsdir(), `${moment().format('YYYY-MM-DD-HH-mm')}-${process.pid}.ndjson`);
|
||||||
|
setLogsFilePath(logsFilePath);
|
||||||
|
|
||||||
let logger = pinoms({
|
let logger = pinoms({
|
||||||
streams: [
|
streams: [
|
||||||
{ stream: process.stdout }, // an "info" level destination stream
|
{ stream: process.stdout }, // an "info" level destination stream
|
||||||
{
|
{
|
||||||
stream: fs.createWriteStream(
|
stream: fs.createWriteStream(logsFilePath),
|
||||||
path.join(logsdir(), `${moment().format('YYYY-MM-DD-HH-mm')}-${process.pid}.ndjson`)
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ const processArgs = require('./processArgs');
|
|||||||
const consoleObjectWriter = require('../shell/consoleObjectWriter');
|
const consoleObjectWriter = require('../shell/consoleObjectWriter');
|
||||||
const { getLogger } = require('dbgate-tools');
|
const { getLogger } = require('dbgate-tools');
|
||||||
|
|
||||||
|
let logsFilePath;
|
||||||
|
|
||||||
const createDirectories = {};
|
const createDirectories = {};
|
||||||
const ensureDirectory = (dir, clean) => {
|
const ensureDirectory = (dir, clean) => {
|
||||||
if (!createDirectories[dir]) {
|
if (!createDirectories[dir]) {
|
||||||
@@ -135,6 +137,14 @@ function migrateDataDir() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setLogsFilePath(value) {
|
||||||
|
logsFilePath = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLogsFilePath() {
|
||||||
|
return logsFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
migrateDataDir();
|
migrateDataDir();
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -153,4 +163,6 @@ module.exports = {
|
|||||||
getPluginBackendPath,
|
getPluginBackendPath,
|
||||||
resolveArchiveFolder,
|
resolveArchiveFolder,
|
||||||
clearArchiveLinksCache,
|
clearArchiveLinksCache,
|
||||||
|
getLogsFilePath,
|
||||||
|
setLogsFilePath,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -451,6 +451,22 @@ registerCommand({
|
|||||||
onClick: openArchiveFolder,
|
onClick: openArchiveFolder,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
registerCommand({
|
||||||
|
id: 'folder.showLogs',
|
||||||
|
category: 'Folder',
|
||||||
|
name: 'Open logs',
|
||||||
|
testEnabled: () => getElectron() != null,
|
||||||
|
onClick: () => electron.showItemInFolder(getCurrentConfig().logsFilePath),
|
||||||
|
});
|
||||||
|
|
||||||
|
registerCommand({
|
||||||
|
id: 'folder.showData',
|
||||||
|
category: 'Folder',
|
||||||
|
name: 'Open data folder',
|
||||||
|
testEnabled: () => getElectron() != null,
|
||||||
|
onClick: () => electron.showItemInFolder(getCurrentConfig().connectionsFilePath),
|
||||||
|
});
|
||||||
|
|
||||||
registerCommand({
|
registerCommand({
|
||||||
id: 'file.import',
|
id: 'file.import',
|
||||||
category: 'File',
|
category: 'File',
|
||||||
|
|||||||
Reference in New Issue
Block a user