mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 20:46:00 +00:00
show logs from menu
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user