From: Jérôme Benoit Date: Mon, 31 Jan 2022 11:31:18 +0000 (+0100) Subject: Fix build due to winston types definition X-Git-Tag: v1.1.45~15 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b35c4a05c709fba23af96a144fecfd9f6e0182ad;p=e-mobility-charging-stations-simulator.git Fix build due to winston types definition Signed-off-by: Jérôme Benoit --- 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, });