Skip to content

Commit

Permalink
Merge pull request #108 from SoftwareAG/better-logs-with-device-id
Browse files Browse the repository at this point in the history
update logs with device c8y id + some logs updated with template strings
  • Loading branch information
cpoder authored Jun 6, 2024
2 parents 999546f + e994ffa commit a1969d7
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions nodejs/c8y-codec-interface/src/lora/codec/DeviceCodec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ export abstract class DeviceCodec implements Component {
async decode(client: Client, decode: Decode): Promise<Result<string>> {
let result: Result<string> = { 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) {
Expand Down Expand Up @@ -83,10 +87,6 @@ export abstract class DeviceCodec implements Component {
result.success = false;
result.message += "Payload is not in hexadecimal format!<br>";
}
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}`);
Expand Down Expand Up @@ -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<IAlarm> = await client.alarm.list({
source: device.id,
type: alarmType,
Expand All @@ -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}`);
}
}
}

0 comments on commit a1969d7

Please sign in to comment.