Log early OCPP command payload
authorJérôme Benoit <jerome.benoit@sap.com>
Wed, 13 Apr 2022 20:13:57 +0000 (22:13 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Wed, 13 Apr 2022 20:13:57 +0000 (22:13 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index 81855ceceb47297e5fc97ab93117f179f8da7cb9..4ed293e4d8c8b91affb4dad96cc6da67c52a428b 100644 (file)
@@ -1504,17 +1504,17 @@ export default class ChargingStation {
           if (this.getEnableStatistics()) {
             this.performanceStatistics.addRequestStatistic(commandName, messageType);
           }
+          logger.debug(
+            `${this.logPrefix()} << Command '${commandName}' received request payload: ${JSON.stringify(
+              request
+            )}`
+          );
           // Process the call
           await this.ocppIncomingRequestService.handleRequest(
             messageId,
             commandName,
             commandPayload
           );
-          logger.debug(
-            `${this.logPrefix()} << Command '${commandName}' received request payload: ${JSON.stringify(
-              request
-            )}`
-          );
           break;
         // Outcome Message
         case MessageType.CALL_RESULT_MESSAGE:
@@ -1529,6 +1529,11 @@ export default class ChargingStation {
               requestCommandName
             );
           }
+          logger.debug(
+            `${this.logPrefix()} << Command '${requestCommandName}' received response payload: ${JSON.stringify(
+              request
+            )}`
+          );
           if (!responseCallback) {
             // Error
             throw new OCPPError(
@@ -1538,11 +1543,6 @@ export default class ChargingStation {
             );
           }
           responseCallback(commandName, requestPayload);
-          logger.debug(
-            `${this.logPrefix()} << Command '${requestCommandName}' received response payload: ${JSON.stringify(
-              request
-            )}`
-          );
           break;
         // Error Message
         case MessageType.CALL_ERROR_MESSAGE:
@@ -1555,6 +1555,11 @@ export default class ChargingStation {
               `Cached request for message id ${messageId} error response is not iterable`
             );
           }
+          logger.debug(
+            `${this.logPrefix()} << Command '${requestCommandName}' received error payload: ${JSON.stringify(
+              request
+            )}`
+          );
           if (!rejectCallback) {
             // Error
             throw new OCPPError(
@@ -1566,11 +1571,6 @@ export default class ChargingStation {
           rejectCallback(
             new OCPPError(commandName, commandPayload.toString(), requestCommandName, errorDetails)
           );
-          logger.debug(
-            `${this.logPrefix()} << Command '${requestCommandName}' received error payload: ${JSON.stringify(
-              request
-            )}`
-          );
           break;
         // Error
         default: