Fix and add log messages
[e-mobility-charging-stations-simulator.git] / src / charging-station / ChargingStation.ts
index 84930a5f628be1f99ed0e010778b55474961729c..547a4f3693321bf271d23cdae07c6cb51df01876 100644 (file)
@@ -1,7 +1,7 @@
 // Partial Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
 
-import crypto from 'crypto';
 import fs from 'fs';
+import crypto from 'node:crypto';
 import path from 'path';
 import { URL } from 'url';
 import { parentPort } from 'worker_threads';
@@ -65,6 +65,7 @@ import {
   type IncomingRequest,
   IncomingRequestCommand,
   type MeterValuesRequest,
+  type OutgoingRequest,
   RequestCommand,
   type ResponseCallback,
   type StatusNotificationRequest,
@@ -769,6 +770,12 @@ export default class ChargingStation {
       this.messageBuffer.forEach((message) => {
         // TODO: evaluate the need to track performance
         this.wsConnection.send(message);
+        const [messageType] = JSON.parse(message) as OutgoingRequest | Response | ErrorResponse;
+        logger.debug(
+          `${this.logPrefix()} >> Buffered ${OCPPServiceUtils.getMessageTypeString(
+            messageType
+          )} payload sent: ${message}`
+        );
         this.messageBuffer.delete(message);
       });
     }