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:
Sebastian MaltonandSebastian Malton authored and GitHub committed 2020-09-01 09:20:59 -04:00
1 parent 533646cba5
commit cb3e19f2f0
3 files changed
+19 -7

No files matched your search

+14 -4
View File
@@ -1,20 +1,30 @@
import { app, remote } from "electron";
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: (app || remote.app).getPath("logs"),
maxsize: 16 * 1024,
maxFiles: 16,
tailable: true,
}
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),
],
});