From 8387cd3144acc55a2eaa20d8cf26745a4456f9d8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 13 Feb 2021 19:05:42 +0100 Subject: [PATCH] Logger.ts: import cleanups MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/utils/Logger.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/utils/Logger.ts b/src/utils/Logger.ts index dfd04e90..ccbc63ca 100644 --- a/src/utils/Logger.ts +++ b/src/utils/Logger.ts @@ -1,27 +1,27 @@ -import 'winston-daily-rotate-file'; - -import winston, { transport } from 'winston'; +import { Console, File } from 'winston/lib/winston/transports'; +import { Logger, createLogger, format, transport } from 'winston'; import Configuration from './Configuration'; +import DailyRotateFile from 'winston-daily-rotate-file'; import Utils from './Utils'; let transports: transport[]; if (Configuration.getLogRotate()) { const logMaxFiles = Configuration.getLogMaxFiles(); transports = [ - new winston.transports.DailyRotateFile({ filename: Utils.insertAt(Configuration.getLogErrorFile(), '-%DATE%', Configuration.getLogErrorFile().indexOf('.log')), level: 'error', maxFiles: logMaxFiles }), - new winston.transports.DailyRotateFile({ filename: Utils.insertAt(Configuration.getLogFile(), '-%DATE%', Configuration.getLogFile().indexOf('.log')), maxFiles: logMaxFiles }), + new DailyRotateFile({ filename: Utils.insertAt(Configuration.getLogErrorFile(), '-%DATE%', Configuration.getLogErrorFile().indexOf('.log')), level: 'error', maxFiles: logMaxFiles }), + new DailyRotateFile({ filename: Utils.insertAt(Configuration.getLogFile(), '-%DATE%', Configuration.getLogFile().indexOf('.log')), maxFiles: logMaxFiles }), ]; } else { transports = [ - new winston.transports.File({ filename: Configuration.getLogErrorFile(), level: 'error' }), - new winston.transports.File({ filename: Configuration.getLogFile() }), + new File({ filename: Configuration.getLogErrorFile(), level: 'error' }), + new File({ filename: Configuration.getLogFile() }), ]; } -const logger = winston.createLogger({ +const logger: Logger = createLogger({ level: Configuration.getLogLevel(), - format: winston.format.combine(winston.format.splat(), winston.format[Configuration.getLogFormat()]()), + format: format.combine(format.splat(), format[Configuration.getLogFormat()]()), transports: transports, }); @@ -30,8 +30,8 @@ const logger = winston.createLogger({ // `${info.level}: ${info.message} JSON.stringify({ ...rest }) ` // if (Configuration.getLogConsole()) { - logger.add(new winston.transports.Console({ - format: winston.format.combine(winston.format.splat(), winston.format[Configuration.getLogFormat()]()), + logger.add(new Console({ + format: format.combine(format.splat(), format[Configuration.getLogFormat()]()), })); } -- 2.34.1