Uniformize log messages format
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 28 Aug 2022 13:59:08 +0000 (15:59 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 28 Aug 2022 13:59:08 +0000 (15:59 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/AutomaticTransactionGenerator.ts
src/charging-station/ocpp/1.6/OCPP16IncomingRequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/ui/web/src/composables/UIClient.ts

index 8869a775d90443050b8630bc62fa88c3a6f006da..a6408d2bd7f4366f16880cdbb421ba8ffb46469a 100644 (file)
@@ -281,6 +281,9 @@ export default class AutomaticTransactionGenerator {
     let startResponse: StartTransactionResponse;
     if (this.chargingStation.hasAuthorizedTags()) {
       const idTag = this.chargingStation.getRandomIdTag();
+      const startTransactionLogMsg = `${this.logPrefix(
+        connectorId
+      )} start transaction for idTag '${idTag}'`;
       if (this.getRequireAuthorize()) {
         this.chargingStation.getConnectorStatus(connectorId).authorizeIdTag = idTag;
         // Authorize idTag
@@ -294,7 +297,7 @@ export default class AutomaticTransactionGenerator {
         this.connectorsStatus.get(connectorId).authorizeRequests++;
         if (authorizeResponse?.idTagInfo?.status === AuthorizationStatus.ACCEPTED) {
           this.connectorsStatus.get(connectorId).acceptedAuthorizeRequests++;
-          logger.info(this.logPrefix(connectorId) + ' start transaction for idTag ' + idTag);
+          logger.info(startTransactionLogMsg);
           // Start transaction
           startResponse = await this.chargingStation.ocppRequestService.requestHandler<
             StartTransactionRequest,
@@ -310,7 +313,7 @@ export default class AutomaticTransactionGenerator {
         PerformanceStatistics.endMeasure(measureId, beginId);
         return authorizeResponse;
       }
-      logger.info(this.logPrefix(connectorId) + ' start transaction for idTag ' + idTag);
+      logger.info(startTransactionLogMsg);
       // Start transaction
       startResponse = await this.chargingStation.ocppRequestService.requestHandler<
         StartTransactionRequest,
@@ -322,7 +325,7 @@ export default class AutomaticTransactionGenerator {
       PerformanceStatistics.endMeasure(measureId, beginId);
       return startResponse;
     }
-    logger.info(this.logPrefix(connectorId) + ' start transaction without an idTag');
+    logger.info(`${this.logPrefix(connectorId)} start transaction without an idTag`);
     startResponse = await this.chargingStation.ocppRequestService.requestHandler<
       StartTransactionRequest,
       StartTransactionResponse
index c870fbc14107624b0f942a09e5c9430c6e3144d6..4f4db66848bd72b4c54dd9776e688ef727f7f3b2 100644 (file)
@@ -831,8 +831,9 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
                     chargingStation.stationInfo.chargingStationId +
                     '#' +
                     transactionConnectorId.toString() +
-                    ' for idTag ' +
-                    commandPayload.idTag
+                    " for idTag '" +
+                    commandPayload.idTag +
+                    "'"
                 );
                 return Constants.OCPP_RESPONSE_ACCEPTED;
               }
@@ -880,8 +881,9 @@ export default class OCPP16IncomingRequestService extends OCPPIncomingRequestSer
                 chargingStation.stationInfo.chargingStationId +
                 '#' +
                 transactionConnectorId.toString() +
-                ' for idTag ' +
-                commandPayload.idTag
+                " for idTag '" +
+                commandPayload.idTag +
+                "'"
             );
             return Constants.OCPP_RESPONSE_ACCEPTED;
           }
index d765e1d25826d1e452b38d025845f26c287bf9a7..c7ab237a21a2bc781c99ce00454a96428fd72fdb 100644 (file)
@@ -292,15 +292,15 @@ export default class OCPP16ResponseService extends OCPPResponseService {
     if (payload.idTagInfo.status === OCPP16AuthorizationStatus.ACCEPTED) {
       chargingStation.getConnectorStatus(authorizeConnectorId).idTagAuthorized = true;
       logger.debug(
-        `${chargingStation.logPrefix()} IdTag ${
+        `${chargingStation.logPrefix()} IdTag '${
           requestPayload.idTag
-        } authorized on connector ${authorizeConnectorId}`
+        }' authorized on connector ${authorizeConnectorId}`
       );
     } else {
       chargingStation.getConnectorStatus(authorizeConnectorId).idTagAuthorized = false;
       delete chargingStation.getConnectorStatus(authorizeConnectorId).authorizeIdTag;
       logger.debug(
-        `${chargingStation.logPrefix()} IdTag ${requestPayload.idTag} refused with status '${
+        `${chargingStation.logPrefix()} IdTag '${requestPayload.idTag}' refused with status '${
           payload.idTagInfo.status
         }' on connector ${authorizeConnectorId}`
       );
@@ -465,8 +465,9 @@ export default class OCPP16ResponseService extends OCPPResponseService {
           chargingStation.stationInfo.chargingStationId +
           '#' +
           connectorId.toString() +
-          ' for idTag ' +
-          requestPayload.idTag
+          " for idTag '" +
+          requestPayload.idTag +
+          "'"
       );
       if (chargingStation.stationInfo.powerSharedByConnectors) {
         chargingStation.powerDivider++;
index 8f76c53251f72b935f32b5bec0079ca13d2cbcb8..275e30e9f8519111cc726e6e171558e900d6048b 100644 (file)
@@ -108,7 +108,7 @@ export default class UIClient {
     resolve: (value: ResponsePayload | PromiseLike<ResponsePayload>) => void,
     reject: (reason?: any) => void
   ): void {
-    this._responseHandlers.set(id, { resolve, reject, procedureName });
+    this._responseHandlers.set(id, { procedureName, resolve, reject });
   }
 
   private getResponseHandler(id: string): ResponseHandler | undefined {