From b35c4a05c709fba23af96a144fecfd9f6e0182ad Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 31 Jan 2022 12:31:18 +0100 Subject: [PATCH] Fix build due to winston types definition MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/types/ConfigurationData.ts | 3 ++- src/utils/Configuration.ts | 5 +++-- src/utils/Logger.ts | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/types/ConfigurationData.ts b/src/types/ConfigurationData.ts index 10f2565a..51eb045a 100644 --- a/src/types/ConfigurationData.ts +++ b/src/types/ConfigurationData.ts @@ -2,6 +2,7 @@ import { ServerOptions } from 'ws'; import { StorageType } from './Storage'; import type { WorkerChoiceStrategy } from 'poolifier'; import { WorkerProcessType } from './Worker'; +import { level } from 'winston'; export interface StationTemplateUrl { file: string; @@ -34,7 +35,7 @@ export default interface ConfigurationData { chargingStationsPerWorker?: number; logStatisticsInterval?: number; logFormat?: string; - logLevel?: string; + logLevel?: level; logRotate?: boolean; logMaxFiles?: number; logFile?: string; diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 8e3675b1..61fe300b 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -7,6 +7,7 @@ import type { WorkerChoiceStrategy } from 'poolifier'; import { WorkerProcessType } from '../types/Worker'; import chalk from 'chalk'; import fs from 'fs'; +import { level } from 'winston'; import path from 'path'; export default class Configuration { @@ -136,8 +137,8 @@ export default class Configuration { return Configuration.objectHasOwnProperty(Configuration.getConfig(), 'logMaxFiles') ? Configuration.getConfig().logMaxFiles : 7; } - static getLogLevel(): string { - return Configuration.objectHasOwnProperty(Configuration.getConfig(), 'logLevel') ? Configuration.getConfig().logLevel : 'info'; + static getLogLevel(): level { + return Configuration.objectHasOwnProperty(Configuration.getConfig(), 'logLevel') ? Configuration.getConfig().logLevel.toLowerCase() as level : 'info'; } static getLogFile(): string { diff --git a/src/utils/Logger.ts b/src/utils/Logger.ts index 2f67f15d..ccbc63ca 100644 --- a/src/utils/Logger.ts +++ b/src/utils/Logger.ts @@ -20,7 +20,7 @@ if (Configuration.getLogRotate()) { } const logger: Logger = createLogger({ - level: Configuration.getLogLevel().toLowerCase(), + level: Configuration.getLogLevel(), format: format.combine(format.splat(), format[Configuration.getLogFormat()]()), transports: transports, }); -- 2.34.1