Improve log messages prefixing
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 26 Jan 2023 22:42:51 +0000 (23:42 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 26 Jan 2023 22:42:51 +0000 (23:42 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
13 files changed:
src/charging-station/ChargingStation.ts
src/charging-station/ChargingStationUtils.ts
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts
src/charging-station/ocpp/2.0/OCPP20IncomingRequestService.ts
src/charging-station/ocpp/2.0/OCPP20RequestService.ts
src/charging-station/ocpp/2.0/OCPP20ResponseService.ts
src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts
src/charging-station/ocpp/OCPPServiceUtils.ts
src/charging-station/ui-server/UIHttpServer.ts
src/charging-station/ui-server/UIWebSocketServer.ts

index b827b92242b8bf76f8af3c24152bff3ad96f76c4..79cf45b8a60166c3caa9cef671f921031956142d 100644 (file)
@@ -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()) ??
+        ''
       } |`
     );
   };
index c40a1476b1e79b97b0e84afc2364174db13bfac4..534a3786e210953acdbdede1c63e6846bb6618f7 100644 (file)
@@ -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
index 6e31a43b80095f9900fce1695ae57b2d16761265..fa3d83284a37342316dd2c234ed7e84eead1695e 100644 (file)
@@ -141,85 +141,113 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
       [
         OCPP16IncomingRequestCommand.RESET,
         OCPP16ServiceUtils.parseJsonSchemaFile<ResetRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/Reset.json'
+          '../../../assets/json-schemas/ocpp/1.6/Reset.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.CLEAR_CACHE,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16ClearCacheRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/ClearCache.json'
+          '../../../assets/json-schemas/ocpp/1.6/ClearCache.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
         OCPP16ServiceUtils.parseJsonSchemaFile<UnlockConnectorRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/UnlockConnector.json'
+          '../../../assets/json-schemas/ocpp/1.6/UnlockConnector.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.GET_CONFIGURATION,
         OCPP16ServiceUtils.parseJsonSchemaFile<GetConfigurationRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/GetConfiguration.json'
+          '../../../assets/json-schemas/ocpp/1.6/GetConfiguration.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
         OCPP16ServiceUtils.parseJsonSchemaFile<ChangeConfigurationRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/ChangeConfiguration.json'
+          '../../../assets/json-schemas/ocpp/1.6/ChangeConfiguration.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
         OCPP16ServiceUtils.parseJsonSchemaFile<GetDiagnosticsRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/GetDiagnostics.json'
+          '../../../assets/json-schemas/ocpp/1.6/GetDiagnostics.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
         OCPP16ServiceUtils.parseJsonSchemaFile<SetChargingProfileRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/SetChargingProfile.json'
+          '../../../assets/json-schemas/ocpp/1.6/SetChargingProfile.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
         OCPP16ServiceUtils.parseJsonSchemaFile<ClearChargingProfileRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfile.json'
+          '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfile.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
         OCPP16ServiceUtils.parseJsonSchemaFile<ChangeAvailabilityRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/ChangeAvailability.json'
+          '../../../assets/json-schemas/ocpp/1.6/ChangeAvailability.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
         OCPP16ServiceUtils.parseJsonSchemaFile<RemoteStartTransactionRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json'
+          '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransaction.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
         OCPP16ServiceUtils.parseJsonSchemaFile<RemoteStopTransactionRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json'
+          '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransaction.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16TriggerMessageRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/TriggerMessage.json'
+          '../../../assets/json-schemas/ocpp/1.6/TriggerMessage.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.DATA_TRANSFER,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DataTransferRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json'
+          '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.UPDATE_FIRMWARE,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16UpdateFirmwareRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/UpdateFirmware.json'
+          '../../../assets/json-schemas/ocpp/1.6/UpdateFirmware.json',
+          moduleName,
+          'constructor'
         ),
       ],
     ]);
index 845506958fb633500504a04ca3eff118df2382cb..98cf531723be791795bd5e1698b3489e4f86bf14 100644 (file)
@@ -44,61 +44,81 @@ export default class OCPP16RequestService extends OCPPRequestService {
       [
         OCPP16RequestCommand.AUTHORIZE,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16AuthorizeRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/Authorize.json'
+          '../../../assets/json-schemas/ocpp/1.6/Authorize.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.BOOT_NOTIFICATION,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16BootNotificationRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/BootNotification.json'
+          '../../../assets/json-schemas/ocpp/1.6/BootNotification.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DiagnosticsStatusNotificationRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotification.json'
+          '../../../assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotification.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.HEARTBEAT,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16HeartbeatRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/Heartbeat.json'
+          '../../../assets/json-schemas/ocpp/1.6/Heartbeat.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.METER_VALUES,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16MeterValuesRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/MeterValues.json'
+          '../../../assets/json-schemas/ocpp/1.6/MeterValues.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.STATUS_NOTIFICATION,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StatusNotificationRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/StatusNotification.json'
+          '../../../assets/json-schemas/ocpp/1.6/StatusNotification.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.START_TRANSACTION,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StartTransactionRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/StartTransaction.json'
+          '../../../assets/json-schemas/ocpp/1.6/StartTransaction.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.STOP_TRANSACTION,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StopTransactionRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/StopTransaction.json'
+          '../../../assets/json-schemas/ocpp/1.6/StopTransaction.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.DATA_TRANSFER,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DataTransferRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json'
+          '../../../assets/json-schemas/ocpp/1.6/DataTransfer.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16FirmwareStatusNotificationRequest>(
-          '../../../assets/json-schemas/ocpp/1.6/FirmwareStatusNotification.json'
+          '../../../assets/json-schemas/ocpp/1.6/FirmwareStatusNotification.json',
+          moduleName,
+          'constructor'
         ),
       ],
     ]);
index 188618ca0e4cb70f5a0e6cd632a2114af1ab1529..5433adecf704f658deeae8683f24d31e92cfb7ce 100644 (file)
@@ -90,61 +90,81 @@ export default class OCPP16ResponseService extends OCPPResponseService {
       [
         OCPP16RequestCommand.BOOT_NOTIFICATION,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16BootNotificationResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/BootNotificationResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/BootNotificationResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.HEARTBEAT,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16HeartbeatResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/HeartbeatResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/HeartbeatResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.AUTHORIZE,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16AuthorizeResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/AuthorizeResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/AuthorizeResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.START_TRANSACTION,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StartTransactionResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/StartTransactionResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/StartTransactionResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.STOP_TRANSACTION,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StopTransactionResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/StopTransactionResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/StopTransactionResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.STATUS_NOTIFICATION,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16StatusNotificationResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/StatusNotificationResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.METER_VALUES,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16MeterValuesResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/MeterValuesResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/MeterValuesResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.DIAGNOSTICS_STATUS_NOTIFICATION,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DiagnosticsStatusNotificationResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/DiagnosticsStatusNotificationResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.DATA_TRANSFER,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DataTransferResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/DataTransferResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/DataTransferResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16RequestCommand.FIRMWARE_STATUS_NOTIFICATION,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16FirmwareStatusNotificationResponse>(
-          '../../../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<GenericResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/ResetResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/ResetResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.CLEAR_CACHE,
         OCPP16ServiceUtils.parseJsonSchemaFile<GenericResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/ClearCacheResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/ClearCacheResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.CHANGE_AVAILABILITY,
         OCPP16ServiceUtils.parseJsonSchemaFile<ChangeAvailabilityResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/ChangeAvailabilityResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.UNLOCK_CONNECTOR,
         OCPP16ServiceUtils.parseJsonSchemaFile<UnlockConnectorResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/UnlockConnectorResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.GET_CONFIGURATION,
         OCPP16ServiceUtils.parseJsonSchemaFile<GetConfigurationResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/GetConfigurationResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.CHANGE_CONFIGURATION,
         OCPP16ServiceUtils.parseJsonSchemaFile<ChangeConfigurationResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/ChangeConfigurationResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.SET_CHARGING_PROFILE,
         OCPP16ServiceUtils.parseJsonSchemaFile<SetChargingProfileResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/SetChargingProfileResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.CLEAR_CHARGING_PROFILE,
         OCPP16ServiceUtils.parseJsonSchemaFile<ClearChargingProfileResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/ClearChargingProfileResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.REMOTE_START_TRANSACTION,
         OCPP16ServiceUtils.parseJsonSchemaFile<GenericResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/RemoteStartTransactionResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.REMOTE_STOP_TRANSACTION,
         OCPP16ServiceUtils.parseJsonSchemaFile<GenericResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/RemoteStopTransactionResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.GET_DIAGNOSTICS,
         OCPP16ServiceUtils.parseJsonSchemaFile<GetDiagnosticsResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/GetDiagnosticsResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.TRIGGER_MESSAGE,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16TriggerMessageResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/TriggerMessageResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.DATA_TRANSFER,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16DataTransferResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/DataTransferResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/DataTransferResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP16IncomingRequestCommand.UPDATE_FIRMWARE,
         OCPP16ServiceUtils.parseJsonSchemaFile<OCPP16UpdateFirmwareResponse>(
-          '../../../assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json'
+          '../../../assets/json-schemas/ocpp/1.6/UpdateFirmwareResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
     ]);
index de9c8548926477a3c73f8de0bd3c5c0bced4aa7c..d0d46c25d50df40ae9fb3f1f4bed5d9fbe196d5d 100644 (file)
@@ -786,10 +786,16 @@ export class OCPP16ServiceUtils extends OCPPServiceUtils {
     !cpReplaced && chargingStation.getConnectorStatus(connectorId)?.chargingProfiles?.push(cp);
   }
 
-  public static parseJsonSchemaFile<T extends JsonType>(relativePath: string): JSONSchemaType<T> {
+  public static parseJsonSchemaFile<T extends JsonType>(
+    relativePath: string,
+    moduleName?: string,
+    methodName?: string
+  ): JSONSchemaType<T> {
     return super.parseJsonSchemaFile<T>(
       path.resolve(path.dirname(fileURLToPath(import.meta.url)), relativePath),
-      OCPPVersion.VERSION_16
+      OCPPVersion.VERSION_16,
+      moduleName,
+      methodName
     );
   }
 
index 03c3cb04428e8e0d880a3f1c7799e9657c4c8557..182f58d7e89a629fd93cb514e376cb99fb0f2a99 100644 (file)
@@ -34,7 +34,9 @@ export default class OCPP20IncomingRequestService extends OCPPIncomingRequestSer
       [
         OCPP20IncomingRequestCommand.CLEAR_CACHE,
         OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20ClearCacheRequest>(
-          '../../../assets/json-schemas/ocpp/2.0/ClearCacheRequest.json'
+          '../../../assets/json-schemas/ocpp/2.0/ClearCacheRequest.json',
+          moduleName,
+          'constructor'
         ),
       ],
     ]);
index 902aa094306cd07f8cfe07580314af910b13e8ad..b9813d59d925b6d9360f5dec9f41fc13cd8a6112 100644 (file)
@@ -34,19 +34,25 @@ export default class OCPP20RequestService extends OCPPRequestService {
       [
         OCPP20RequestCommand.BOOT_NOTIFICATION,
         OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20BootNotificationRequest>(
-          '../../../assets/json-schemas/ocpp/2.0/BootNotificationRequest.json'
+          '../../../assets/json-schemas/ocpp/2.0/BootNotificationRequest.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP20RequestCommand.HEARTBEAT,
         OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20HeartbeatRequest>(
-          '../../../assets/json-schemas/ocpp/2.0/HeartbeatRequest.json'
+          '../../../assets/json-schemas/ocpp/2.0/HeartbeatRequest.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP20RequestCommand.STATUS_NOTIFICATION,
         OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20StatusNotificationRequest>(
-          '../../../assets/json-schemas/ocpp/2.0/StatusNotificationRequest.json'
+          '../../../assets/json-schemas/ocpp/2.0/StatusNotificationRequest.json',
+          moduleName,
+          'constructor'
         ),
       ],
     ]);
index 6e63c8a45d2d6666771ea156b62ea653782d954b..ee4c16065aa6239127cb9ee90755fdc208ee4f78 100644 (file)
@@ -47,19 +47,25 @@ export default class OCPP20ResponseService extends OCPPResponseService {
       [
         OCPP20RequestCommand.BOOT_NOTIFICATION,
         OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20BootNotificationResponse>(
-          '../../../assets/json-schemas/ocpp/2.0/BootNotificationResponse.json'
+          '../../../assets/json-schemas/ocpp/2.0/BootNotificationResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP20RequestCommand.HEARTBEAT,
         OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20HeartbeatResponse>(
-          '../../../assets/json-schemas/ocpp/2.0/HeartbeatResponse.json'
+          '../../../assets/json-schemas/ocpp/2.0/HeartbeatResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
       [
         OCPP20RequestCommand.STATUS_NOTIFICATION,
         OCPP20ServiceUtils.parseJsonSchemaFile<OCPP20StatusNotificationResponse>(
-          '../../../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<OCPP20ClearCacheResponse>(
-          '../../../assets/json-schemas/ocpp/2.0/ClearCacheResponse.json'
+          '../../../assets/json-schemas/ocpp/2.0/ClearCacheResponse.json',
+          moduleName,
+          'constructor'
         ),
       ],
     ]);
index e6f5c7adf7243e43f2ae52ddd8b6516831aae4e9..b155f462d2615a65e83f1580435709bb081d59f7 100644 (file)
@@ -10,10 +10,16 @@ import { OCPPVersion } from '../../../types/ocpp/OCPPVersion';
 import { OCPPServiceUtils } from '../OCPPServiceUtils';
 
 export class OCPP20ServiceUtils extends OCPPServiceUtils {
-  public static parseJsonSchemaFile<T extends JsonType>(relativePath: string): JSONSchemaType<T> {
+  public static parseJsonSchemaFile<T extends JsonType>(
+    relativePath: string,
+    moduleName?: string,
+    methodName?: string
+  ): JSONSchemaType<T> {
     return super.parseJsonSchemaFile<T>(
       path.resolve(path.dirname(fileURLToPath(import.meta.url)), relativePath),
-      OCPPVersion.VERSION_20
+      OCPPVersion.VERSION_20,
+      moduleName,
+      methodName
     );
   }
 }
index 6d21182891224ec436dba3946993b776d3cc6eb4..308f6b41239c10a5bde0eadd5bb4414595eba1ce 100644 (file)
@@ -170,7 +170,9 @@ export class OCPPServiceUtils {
 
   protected static parseJsonSchemaFile<T extends JsonType>(
     filePath: string,
-    ocppVersion: OCPPVersion
+    ocppVersion: OCPPVersion,
+    moduleName?: string,
+    methodName?: string
   ): JSONSchemaType<T> {
     try {
       return JSON.parse(fs.readFileSync(filePath, 'utf8')) as JSONSchemaType<T>;
@@ -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);
   };
 }
index 50bdfb592d1ac73291f62a2e68005406646fc353..f339dc3f858687ddbb6a46385f8a64d005bd7136 100644 (file)
@@ -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);
   };
 
index c00b8c28f6f8adb2d794733b265604a49135fc51..a8abad0b6f6d85b14d06c0b6195853d0e51ae290 100644 (file)
@@ -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);
   };