mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Allow for users to enabled release mode debugging (#481)
* Allow for users to enabled release mode debugging by setting the env var `DEBUG` to "true" * Adds file logging so that in production logs can still be obtained. Those log files are limited the size and number and are rotated automatically Signed-off-by: Sebastian Malton <smalton@mirantis.com> Co-authored-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
parent
533646cba5
commit
cb3e19f2f0
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@ static/build/**
|
|||||||
binaries/client/
|
binaries/client/
|
||||||
binaries/server/
|
binaries/server/
|
||||||
locales/**/**.js
|
locales/**/**.js
|
||||||
|
lens.log
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import logger from "./logger"
|
|||||||
|
|
||||||
const workingDir = path.join(app.getPath("appData"), appName);
|
const workingDir = path.join(app.getPath("appData"), appName);
|
||||||
app.setName(appName);
|
app.setName(appName);
|
||||||
if(!process.env.CICD) {
|
if (!process.env.CICD) {
|
||||||
app.setPath("userData", workingDir);
|
app.setPath("userData", workingDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,8 @@ async function main() {
|
|||||||
try {
|
try {
|
||||||
proxyPort = await getFreePort()
|
proxyPort = await getFreePort()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await dialog.showErrorBox("Lens Error", "Could not find a free port for the cluster proxy")
|
logger.error(error)
|
||||||
|
dialog.showErrorBox("Lens Error", "Could not find a free port for the cluster proxy")
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +69,7 @@ async function main() {
|
|||||||
proxyServer = LensProxy.create(proxyPort, clusterManager);
|
proxyServer = LensProxy.create(proxyPort, clusterManager);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(`Could not start proxy (127.0.0:${proxyPort}): ${error.message}`)
|
logger.error(`Could not start proxy (127.0.0:${proxyPort}): ${error.message}`)
|
||||||
await dialog.showErrorBox("Lens Error", `Could not start proxy (127.0.0:${proxyPort}): ${error.message || "unknown error"}`)
|
dialog.showErrorBox("Lens Error", `Could not start proxy (127.0.0:${proxyPort}): ${error.message || "unknown error"}`)
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,20 +1,30 @@
|
|||||||
|
import { app, remote } from "electron";
|
||||||
import winston from "winston"
|
import winston from "winston"
|
||||||
import { isDebugging } from "../common/vars";
|
import { isDebugging } from "../common/vars";
|
||||||
|
|
||||||
const options = {
|
const consoleOptions: winston.transports.ConsoleTransportOptions = {
|
||||||
colorize: true,
|
|
||||||
handleExceptions: false,
|
handleExceptions: false,
|
||||||
json: false,
|
|
||||||
level: isDebugging ? "debug" : "info",
|
level: isDebugging ? "debug" : "info",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const fileOptions: winston.transports.FileTransportOptions = {
|
||||||
|
handleExceptions: false,
|
||||||
|
level: isDebugging ? "debug" : "info",
|
||||||
|
filename: "lens.log",
|
||||||
|
dirname: (app || remote.app).getPath("logs"),
|
||||||
|
maxsize: 16 * 1024,
|
||||||
|
maxFiles: 16,
|
||||||
|
tailable: true,
|
||||||
|
}
|
||||||
|
|
||||||
const logger = winston.createLogger({
|
const logger = winston.createLogger({
|
||||||
format: winston.format.combine(
|
format: winston.format.combine(
|
||||||
winston.format.colorize(),
|
winston.format.colorize(),
|
||||||
winston.format.simple(),
|
winston.format.simple(),
|
||||||
),
|
),
|
||||||
transports: [
|
transports: [
|
||||||
new winston.transports.Console(options),
|
new winston.transports.Console(consoleOptions),
|
||||||
|
new winston.transports.File(fileOptions),
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user