From: Jérôme Benoit Date: Thu, 26 Jan 2023 22:42:51 +0000 (+0100) Subject: Improve log messages prefixing X-Git-Tag: v1.1.93~34 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1b271a549cfd1b8e678a56918f113ebc7c17f592;p=e-mobility-charging-stations-simulator.git Improve log messages prefixing Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index b827b922..79cf45b8 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -160,8 +160,10 @@ export default class ChargingStation { public logPrefix = (): string => { return Utils.logPrefix( ` ${ - this?.stationInfo?.chargingStationId ?? - ChargingStationUtils.getChargingStationId(this.index, this.getTemplateFromFile()) + (!Utils.isEmptyString(this?.stationInfo?.chargingStationId) && + this?.stationInfo?.chargingStationId) ?? + ChargingStationUtils.getChargingStationId(this.index, this.getTemplateFromFile()) ?? + '' } |` ); }; diff --git a/src/charging-station/ChargingStationUtils.ts b/src/charging-station/ChargingStationUtils.ts index c40a1476..534a3786 100644 --- a/src/charging-station/ChargingStationUtils.ts +++ b/src/charging-station/ChargingStationUtils.ts @@ -43,7 +43,7 @@ export class ChargingStationUtils { ): string { // In case of multiple instances: add instance index to charging station id const instanceIndex = process.env.CF_INSTANCE_INDEX ?? 0; - const idSuffix = stationTemplate.nameSuffix ?? ''; + const idSuffix = stationTemplate?.nameSuffix ?? ''; const idStr = `000000000${index.toString()}`; return stationTemplate?.fixedName ? stationTemplate.baseName diff --git a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts index 6e31a43b..fa3d8328 100644 --- a/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts @@ -141,85 +141,113 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer [ OCPP16IncomingRequestCommand.RESET, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/Reset.json' + '../../../assets/json-schemas/ocpp/1.6/Reset.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.CLEAR_CACHE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ClearCache.json' + '../../../assets/json-schemas/ocpp/1.6/ClearCache.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/UnlockConnector.json' + '../../../assets/json-schemas/ocpp/1.6/UnlockConnector.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.GET_CONFIGURATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/GetConfiguration.json' + '../../../assets/json-schemas/ocpp/1.6/GetConfiguration.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ChangeConfiguration.json' + '../../../assets/json-schemas/ocpp/1.6/ChangeConfiguration.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/GetDiagnostics.json' + '../../../assets/json-schemas/ocpp/1.6/GetDiagnostics.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/SetChargingProfile.json' + '../../../assets/json-schemas/ocpp/1.6/SetChargingProfile.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfile.json' + '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfile.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ChangeAvailability.json' + '../../../assets/json-schemas/ocpp/1.6/ChangeAvailability.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json' + '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json' + '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/TriggerMessage.json' + '../../../assets/json-schemas/ocpp/1.6/TriggerMessage.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.DATA_TRANSFER, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json' + '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.UPDATE_FIRMWARE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/UpdateFirmware.json' + '../../../assets/json-schemas/ocpp/1.6/UpdateFirmware.json', + moduleName, + 'constructor' ), ], ]); diff --git a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts index 84550695..98cf5317 100644 --- a/src/charging-station/ocpp/1.6/OCPP16RequestService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16RequestService.ts @@ -44,61 +44,81 @@ export default class OCPP16RequestService extends OCPPRequestService { [ OCPP16RequestCommand.AUTHORIZE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/Authorize.json' + '../../../assets/json-schemas/ocpp/1.6/Authorize.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.BOOT_NOTIFICATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/BootNotification.json' + '../../../assets/json-schemas/ocpp/1.6/BootNotification.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotification.json' + '../../../assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotification.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.HEARTBEAT, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/Heartbeat.json' + '../../../assets/json-schemas/ocpp/1.6/Heartbeat.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.METER_VALUES, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/MeterValues.json' + '../../../assets/json-schemas/ocpp/1.6/MeterValues.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.STATUS_NOTIFICATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/StatusNotification.json' + '../../../assets/json-schemas/ocpp/1.6/StatusNotification.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.START_TRANSACTION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/StartTransaction.json' + '../../../assets/json-schemas/ocpp/1.6/StartTransaction.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.STOP_TRANSACTION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/StopTransaction.json' + '../../../assets/json-schemas/ocpp/1.6/StopTransaction.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.DATA_TRANSFER, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json' + '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/FirmwareStatusNotification.json' + '../../../assets/json-schemas/ocpp/1.6/FirmwareStatusNotification.json', + moduleName, + 'constructor' ), ], ]); diff --git a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts index 188618ca..5433adec 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ResponseService.ts @@ -90,61 +90,81 @@ export default class OCPP16ResponseService extends OCPPResponseService { [ OCPP16RequestCommand.BOOT_NOTIFICATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/BootNotificationResponse.json' + '../../../assets/json-schemas/ocpp/1.6/BootNotificationResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.HEARTBEAT, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/HeartbeatResponse.json' + '../../../assets/json-schemas/ocpp/1.6/HeartbeatResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.AUTHORIZE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/AuthorizeResponse.json' + '../../../assets/json-schemas/ocpp/1.6/AuthorizeResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.START_TRANSACTION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/StartTransactionResponse.json' + '../../../assets/json-schemas/ocpp/1.6/StartTransactionResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.STOP_TRANSACTION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/StopTransactionResponse.json' + '../../../assets/json-schemas/ocpp/1.6/StopTransactionResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.STATUS_NOTIFICATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json' + '../../../assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.METER_VALUES, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/MeterValuesResponse.json' + '../../../assets/json-schemas/ocpp/1.6/MeterValuesResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json' + '../../../assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.DATA_TRANSFER, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/DataTransferResponse.json' + '../../../assets/json-schemas/ocpp/1.6/DataTransferResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/FirmwareStatusNotificationResponse.json' + '../../../assets/json-schemas/ocpp/1.6/FirmwareStatusNotificationResponse.json', + moduleName, + 'constructor' ), ], ]); @@ -152,85 +172,113 @@ export default class OCPP16ResponseService extends OCPPResponseService { [ OCPP16IncomingRequestCommand.RESET, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ResetResponse.json' + '../../../assets/json-schemas/ocpp/1.6/ResetResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.CLEAR_CACHE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ClearCacheResponse.json' + '../../../assets/json-schemas/ocpp/1.6/ClearCacheResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json' + '../../../assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json' + '../../../assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.GET_CONFIGURATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json' + '../../../assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json' + '../../../assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json' + '../../../assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json' + '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json' + '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json' + '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.GET_DIAGNOSTICS, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json' + '../../../assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.TRIGGER_MESSAGE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json' + '../../../assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.DATA_TRANSFER, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/DataTransferResponse.json' + '../../../assets/json-schemas/ocpp/1.6/DataTransferResponse.json', + moduleName, + 'constructor' ), ], [ OCPP16IncomingRequestCommand.UPDATE_FIRMWARE, OCPP16ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json' + '../../../assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json', + moduleName, + 'constructor' ), ], ]); diff --git a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts index de9c8548..d0d46c25 100644 --- a/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts +++ b/src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts @@ -786,10 +786,16 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils { !cpReplaced && chargingStation.getConnectorStatus(connectorId)?.chargingProfiles?.push(cp); } - public static parseJsonSchemaFile(relativePath: string): JSONSchemaType { + public static parseJsonSchemaFile( + relativePath: string, + moduleName?: string, + methodName?: string + ): JSONSchemaType { return super.parseJsonSchemaFile( path.resolve(path.dirname(fileURLToPath(import.meta.url)), relativePath), - OCPPVersion.VERSION_16 + OCPPVersion.VERSION_16, + moduleName, + methodName ); } diff --git a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts index 03c3cb04..182f58d7 100644 --- a/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts @@ -34,7 +34,9 @@ export default class OCPP20IncomingRequestService extends OCPPIncomingRequestSer [ OCPP20IncomingRequestCommand.CLEAR_CACHE, OCPP20ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/2.0/ClearCacheRequest.json' + '../../../assets/json-schemas/ocpp/2.0/ClearCacheRequest.json', + moduleName, + 'constructor' ), ], ]); diff --git a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts index 902aa094..b9813d59 100644 --- a/src/charging-station/ocpp/2.0/OCPP20RequestService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20RequestService.ts @@ -34,19 +34,25 @@ export default class OCPP20RequestService extends OCPPRequestService { [ OCPP20RequestCommand.BOOT_NOTIFICATION, OCPP20ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/2.0/BootNotificationRequest.json' + '../../../assets/json-schemas/ocpp/2.0/BootNotificationRequest.json', + moduleName, + 'constructor' ), ], [ OCPP20RequestCommand.HEARTBEAT, OCPP20ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/2.0/HeartbeatRequest.json' + '../../../assets/json-schemas/ocpp/2.0/HeartbeatRequest.json', + moduleName, + 'constructor' ), ], [ OCPP20RequestCommand.STATUS_NOTIFICATION, OCPP20ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/2.0/StatusNotificationRequest.json' + '../../../assets/json-schemas/ocpp/2.0/StatusNotificationRequest.json', + moduleName, + 'constructor' ), ], ]); diff --git a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts index 6e63c8a4..ee4c1606 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ResponseService.ts @@ -47,19 +47,25 @@ export default class OCPP20ResponseService extends OCPPResponseService { [ OCPP20RequestCommand.BOOT_NOTIFICATION, OCPP20ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/2.0/BootNotificationResponse.json' + '../../../assets/json-schemas/ocpp/2.0/BootNotificationResponse.json', + moduleName, + 'constructor' ), ], [ OCPP20RequestCommand.HEARTBEAT, OCPP20ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/2.0/HeartbeatResponse.json' + '../../../assets/json-schemas/ocpp/2.0/HeartbeatResponse.json', + moduleName, + 'constructor' ), ], [ OCPP20RequestCommand.STATUS_NOTIFICATION, OCPP20ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/2.0/StatusNotificationResponse.json' + '../../../assets/json-schemas/ocpp/2.0/StatusNotificationResponse.json', + moduleName, + 'constructor' ), ], ]); @@ -67,7 +73,9 @@ export default class OCPP20ResponseService extends OCPPResponseService { [ OCPP20IncomingRequestCommand.CLEAR_CACHE, OCPP20ServiceUtils.parseJsonSchemaFile( - '../../../assets/json-schemas/ocpp/2.0/ClearCacheResponse.json' + '../../../assets/json-schemas/ocpp/2.0/ClearCacheResponse.json', + moduleName, + 'constructor' ), ], ]); diff --git a/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts b/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts index e6f5c7ad..b155f462 100644 --- a/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts +++ b/src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts @@ -10,10 +10,16 @@ import { OCPPVersion } from '../../../types/ocpp/OCPPVersion'; import { OCPPServiceUtils } from '../OCPPServiceUtils'; export class OCPP20ServiceUtils extends OCPPServiceUtils { - public static parseJsonSchemaFile(relativePath: string): JSONSchemaType { + public static parseJsonSchemaFile( + relativePath: string, + moduleName?: string, + methodName?: string + ): JSONSchemaType { return super.parseJsonSchemaFile( path.resolve(path.dirname(fileURLToPath(import.meta.url)), relativePath), - OCPPVersion.VERSION_20 + OCPPVersion.VERSION_20, + moduleName, + methodName ); } } diff --git a/src/charging-station/ocpp/OCPPServiceUtils.ts b/src/charging-station/ocpp/OCPPServiceUtils.ts index 6d211828..308f6b41 100644 --- a/src/charging-station/ocpp/OCPPServiceUtils.ts +++ b/src/charging-station/ocpp/OCPPServiceUtils.ts @@ -170,7 +170,9 @@ export class OCPPServiceUtils { protected static parseJsonSchemaFile( filePath: string, - ocppVersion: OCPPVersion + ocppVersion: OCPPVersion, + moduleName?: string, + methodName?: string ): JSONSchemaType { try { return JSON.parse(fs.readFileSync(filePath, 'utf8')) as JSONSchemaType; @@ -179,7 +181,7 @@ export class OCPPServiceUtils { filePath, FileType.JsonSchema, error as NodeJS.ErrnoException, - OCPPServiceUtils.logPrefix(ocppVersion), + OCPPServiceUtils.logPrefix(ocppVersion, moduleName, methodName), { throwError: false } ); } @@ -283,7 +285,15 @@ export class OCPPServiceUtils { : numberValue * options.unitMultiplier; } - private static logPrefix = (ocppVersion: OCPPVersion): string => { - return Utils.logPrefix(` OCPP ${ocppVersion} |`); + private static logPrefix = ( + ocppVersion: OCPPVersion, + moduleName?: string, + methodName?: string + ): string => { + const logMsg = + !Utils.isEmptyString(moduleName) && !Utils.isEmptyString(methodName) + ? ` OCPP ${ocppVersion} | ${moduleName}.${methodName}:` + : ` OCPP ${ocppVersion} |`; + return Utils.logPrefix(logMsg); }; } diff --git a/src/charging-station/ui-server/UIHttpServer.ts b/src/charging-station/ui-server/UIHttpServer.ts index 50bdfb59..f339dc3f 100644 --- a/src/charging-station/ui-server/UIHttpServer.ts +++ b/src/charging-station/ui-server/UIHttpServer.ts @@ -63,7 +63,9 @@ export default class UIHttpServer extends AbstractUIServer { public logPrefix = (modName?: string, methodName?: string, prefixSuffix?: string): string => { const logMsgPrefix = prefixSuffix ? `UI HTTP Server ${prefixSuffix}` : 'UI HTTP Server'; const logMsg = - modName && methodName ? ` ${logMsgPrefix} | ${modName}.${methodName}:` : ` ${logMsgPrefix} |`; + !Utils.isEmptyString(modName) && !Utils.isEmptyString(methodName) + ? ` ${logMsgPrefix} | ${modName}.${methodName}:` + : ` ${logMsgPrefix} |`; return Utils.logPrefix(logMsg); }; diff --git a/src/charging-station/ui-server/UIWebSocketServer.ts b/src/charging-station/ui-server/UIWebSocketServer.ts index c00b8c28..a8abad0b 100644 --- a/src/charging-station/ui-server/UIWebSocketServer.ts +++ b/src/charging-station/ui-server/UIWebSocketServer.ts @@ -150,7 +150,9 @@ export default class UIWebSocketServer extends AbstractUIServer { ? `UI WebSocket Server ${prefixSuffix}` : 'UI WebSocket Server'; const logMsg = - modName && methodName ? ` ${logMsgPrefix} | ${modName}.${methodName}:` : ` ${logMsgPrefix} |`; + !Utils.isEmptyString(modName) && !Utils.isEmptyString(methodName) + ? ` ${logMsgPrefix} | ${modName}.${methodName}:` + : ` ${logMsgPrefix} |`; return Utils.logPrefix(logMsg); };