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