1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/main/logger.ts
Lauri Nevala 77895d40b0
Move verbose log lines to silly level (#859)
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
2020-09-11 14:11:36 +03:00

34 lines
857 B
TypeScript

import { app, remote } from "electron";
import winston from "winston"
import { isDebugging } from "../common/vars";
const logLevel = process.env.LOG_LEVEL ? process.env.LOG_LEVEL : isDebugging ? "debug" : "info"
const consoleOptions: winston.transports.ConsoleTransportOptions = {
handleExceptions: false,
level: logLevel,
}
const fileOptions: winston.transports.FileTransportOptions = {
handleExceptions: false,
level: logLevel,
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