From e994ffa987d0e6e40ba9b3d047bf8dc962763705 Mon Sep 17 00:00:00 2001 From: Philippe Crabier Date: Wed, 5 Jun 2024 12:53:52 +0000 Subject: [PATCH] update logs with device c8y id + some logs updated with template strings --- .../src/lora/codec/DeviceCodec.ts | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/nodejs/c8y-codec-interface/src/lora/codec/DeviceCodec.ts b/nodejs/c8y-codec-interface/src/lora/codec/DeviceCodec.ts index e30ce2474..f254856f0 100644 --- a/nodejs/c8y-codec-interface/src/lora/codec/DeviceCodec.ts +++ b/nodejs/c8y-codec-interface/src/lora/codec/DeviceCodec.ts @@ -50,8 +50,12 @@ export abstract class DeviceCodec implements Component { async decode(client: Client, decode: Decode): Promise> { let result: Result = { success: true, message: "", response: null }; try { + let device: IManagedObject = await this.getDevice( + client, + decode.deveui.toLowerCase() + ); this.logger.info( - `Processing payload ${decode.payload} from port ${decode.fPort} for device ${decode.deveui} with time ${decode.updateTime}` + `Processing payload ${decode.payload} from port ${decode.fPort} for device deveui=${decode.deveui} / id=${device.id} with time ${decode.updateTime}` ); let datetime: Date; if (!decode.updateTime) { @@ -83,10 +87,6 @@ export abstract class DeviceCodec implements Component { result.success = false; result.message += "Payload is not in hexadecimal format!
"; } - let device: IManagedObject = await this.getDevice( - client, - decode.deveui.toLowerCase() - ); if (result.success) { if (!device) { this.logger.error(`There is no device with DevEUI ${decode.deveui}`); @@ -287,8 +287,9 @@ export abstract class DeviceCodec implements Component { alarmType: string ) { this.logger.info( - "Will clear alarms of type " + alarmType + " on device " + device.name + `Will clear alarms of type ${alarmType} on device deveui=${device.name} / id=${device.id}` ); + let alarms: IResultList = await client.alarm.list({ source: device.id, type: alarmType, @@ -304,12 +305,7 @@ export abstract class DeviceCodec implements Component { }); }); } else { - this.logger.info( - "No alarms to update with type " + - alarmType + - " on device " + - device.name - ); + this.logger.info(`No alarms to update with type ${alarmType} on device deveui=${device.name} /id=${device.id}`); } } }