1
0
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

* If a ENV var is set then the menu options are present

* This PR also prevents some menu options from throwing exceptions if
  the main window is closed.

* This PR also adds file logging so that in production logs can still be
  obtained

Signed-off-by: Sebastian Malton <smalton@mirantis.com>
This commit is contained in:
Sebastian Malton 2020-06-16 14:03:30 -04:00
parent 6e645eade0
commit 862b597a75
3 changed files with 15 additions and 7 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ static/build/**
binaries/client/
binaries/server/
locales/**/**.js
lens.log

View File

@ -21,7 +21,7 @@ import logger from "./logger"
const workingDir = path.join(app.getPath("appData"), appName);
app.setName(appName);
if(!process.env.CICD) {
if (!process.env.CICD) {
app.setPath("userData", workingDir);
}
@ -49,7 +49,8 @@ async function main() {
try {
proxyPort = await getFreePort()
} 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();
}
@ -68,7 +69,7 @@ async function main() {
proxyServer = LensProxy.create(proxyPort, clusterManager);
} catch (error) {
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();
}

View File

@ -1,20 +1,26 @@
import winston from "winston"
import { isDebugging } from "../common/vars";
const options = {
colorize: true,
const consoleOptions: winston.transports.ConsoleTransportOptions = {
handleExceptions: false,
json: false,
level: isDebugging ? "debug" : "info",
}
const fileOptions: winston.transports.FileTransportOptions = {
handleExceptions: false,
level: isDebugging ? "debug" : "info",
filename: "lens.log",
dirname: __dirname,
}
const logger = winston.createLogger({
format: winston.format.combine(
winston.format.colorize(),
winston.format.simple(),
),
transports: [
new winston.transports.Console(options),
new winston.transports.Console(consoleOptions),
new winston.transports.File(fileOptions),
],
});