From 410a760d4c5c78005eede71c94acb6e9a56593c9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 30 Nov 2021 22:03:16 +0100 Subject: [PATCH] Refine UI WS service log messages MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/UIWebSocketServer.ts | 6 +++--- .../UIWebSocketServices/AbstractUIService.ts | 1 - src/charging-station/UIWebSocketServices/UIServiceUtils.ts | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/charging-station/UIWebSocketServer.ts b/src/charging-station/UIWebSocketServer.ts index 78ca7516..f941b138 100644 --- a/src/charging-station/UIWebSocketServer.ts +++ b/src/charging-station/UIWebSocketServer.ts @@ -30,7 +30,7 @@ export default class UIWebSocketServer extends WebSocket.Server { const version = socket.protocol.substring(protocolIndex + Protocol.UI.length) as ProtocolVersion; this.uiService = UIServiceFactory.getUIServiceImplementation(version, this); if (!this.uiService) { - throw new BaseError(`Could not find a UI service implementation for protocol version ${version}`); + throw new BaseError(`Could not find a UI service implementation for UI protocol version ${version}`); } // FIXME: check connection validity socket.on('message', (messageData) => { @@ -39,7 +39,7 @@ export default class UIWebSocketServer extends WebSocket.Server { if (Utils.isIterable(protocolRequest)) { [command, payload] = protocolRequest; } else { - throw new BaseError('Protocol request is not iterable'); + throw new BaseError('UI protocol request is not iterable'); } this.uiService.handleMessage(command, payload).catch(() => { logger.error(`${this.logPrefix()} Error while handling command %s message: %j`, command, payload); @@ -56,6 +56,6 @@ export default class UIWebSocketServer extends WebSocket.Server { } public logPrefix(): string { - return Utils.logPrefix('WebSocket Server:'); + return Utils.logPrefix(' UI WebSocket Server:'); } } diff --git a/src/charging-station/UIWebSocketServices/AbstractUIService.ts b/src/charging-station/UIWebSocketServices/AbstractUIService.ts index fafcdb6d..a817c859 100644 --- a/src/charging-station/UIWebSocketServices/AbstractUIService.ts +++ b/src/charging-station/UIWebSocketServices/AbstractUIService.ts @@ -12,7 +12,6 @@ export default abstract class AbstractUIService { constructor(uiWebSocketServer: UIWebSocketServer) { this.chargingStations = new Set(); this.uiWebSocketServer = uiWebSocketServer; - // TODO: Move the shared service code to AbstractUIService this.messageHandlers = new Map([ [ProtocolCommand.LIST_CHARGING_STATIONS, this.handleListChargingStations.bind(this)], ]); diff --git a/src/charging-station/UIWebSocketServices/UIServiceUtils.ts b/src/charging-station/UIWebSocketServices/UIServiceUtils.ts index f95a7485..2c37e80a 100644 --- a/src/charging-station/UIWebSocketServices/UIServiceUtils.ts +++ b/src/charging-station/UIWebSocketServices/UIServiceUtils.ts @@ -17,7 +17,7 @@ export class UIServiceUtils { return fullProtocol; } } - logger.error(`${Utils.logPrefix('WebSocket Server:')} Unsupported protocol: ${protocol} or protocol version: ${version}`); + logger.error(`${Utils.logPrefix(' UI WebSocket Server:')} Unsupported protocol: ${protocol} or protocol version: ${version}`); return false; }; } -- 2.34.1