1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/main/logger.ts
Sebastian Malton cb3e19f2f0
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>
2020-09-01 09:20:59 -04:00

32 lines
802 B
TypeScript

import { app, remote } from "electron";
import winston from "winston"
import { isDebugging } from "../common/vars";
const consoleOptions: winston.transports.ConsoleTransportOptions = {
handleExceptions: 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(consoleOptions),
new winston.transports.File(fileOptions),
],
});
export default logger