Skip to content

Commit ab36462

Browse files
committed
reduce return paths and rename function
1 parent 416c508 commit ab36462

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

azure/activity_logs_monitoring/index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,30 +383,28 @@ class EventhubLogHandler {
383383
this.records.push(originalRecord);
384384
}
385385
} else {
386-
this.records.push(this.fixPropertiesJsonString(originalRecord));
386+
this.records.push(this.formatProperties(originalRecord));
387387
}
388388
} else {
389389
record = this.addTagsToStringLog(record);
390390
this.records.push(record);
391391
}
392392
}
393393

394-
fixPropertiesJsonString(record) {
394+
formatProperties(record) {
395395
// Check if properties field is a malformed JSON String
396396
if (Object.hasOwn(record, 'properties') && (typeof record.properties === 'string') && (record.properties.includes("':'"))) {
397397
try {
398398
// If the check is true, find and replace single quotes
399399
// with double quotes, to make a proper JSON
400400
// which is then converted into a JSON Object
401-
record.properties = JSON.parse(record.properties.replace(/'/g, '"'));
402-
return record;
401+
parsedProperties = JSON.parse(record.properties.replace(/'/g, '"'));
402+
record.properties = parsedProperties;
403403
} catch {
404404
this.context.error('Unable to fix properties field to JSON Object');
405-
return record;
406405
}
407-
} else {
408-
return record;
409406
}
407+
return record;
410408
}
411409

412410
handleLogs(logs) {

0 commit comments

Comments
 (0)