From 01454454c73ddf5c41d16e7026a34583dceb0b00 Mon Sep 17 00:00:00 2001 From: Peter Blazejewicz Date: Sat, 22 Jun 2019 22:16:55 +0200 Subject: [PATCH] Change Winston logger creation --- src/util/logger.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/util/logger.ts b/src/util/logger.ts index dba312a..5082624 100644 --- a/src/util/logger.ts +++ b/src/util/logger.ts @@ -1,16 +1,18 @@ -import winston from "winston"; -import { Logger } from "winston"; +import { Logger, LoggerOptions, transports } from "winston"; -const logger = new (Logger)({ - transports: [ - new (winston.transports.Console)({ level: process.env.NODE_ENV === "production" ? "error" : "debug" }), - new (winston.transports.File)({ filename: "debug.log", level: "debug"}) - ] -}); +const options: LoggerOptions = { + transports: [ + new transports.Console({ + level: process.env.NODE_ENV === "production" ? "error" : "debug" + }), + new transports.File({ filename: "debug.log", level: "debug" }) + ] +}; + +const logger = new Logger(options); if (process.env.NODE_ENV !== "production") { - logger.debug("Logging initialized at debug level"); + logger.debug("Logging initialized at debug level"); } export default logger; -