Skip to content

Commit 732ab04

Browse files
committed
Apply review suggestions
1 parent 16dbf58 commit 732ab04

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

docs/general-usage/04-custom-fields.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ info("Test data", {"field": 42});
4141

4242
### SAP Cloud Logging
4343

44-
When using the library with SAP Cloud Logging custom fields get added as top-level fields.
44+
When using the library with SAP Cloud Logging, custom fields get added as top-level fields.
4545
Registering custom fields is not required in this case.
4646

4747
By default all custom field values get stringified, which can help to prevent field type mismatches when indexing to SAP Cloud Logging.
48-
However, if you want to retain the original type of your custom fields you can change the type conversion configuration accordingly:
48+
However, if you want to retain the original type of your custom fields, you can change the type conversion configuration accordingly:
4949

5050
```js
5151
log.setCustomFieldsTypeConversion(CustomFieldsTypeConversion.Retain)

src/lib/logger/recordFactory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ export default class RecordFactory {
115115
|| record.payload[key] != null || this.config.isSettable(key)) {
116116
// Stringify, if conversion type 'stringify' is selected and value is not a string already.
117117
if (customFieldsTypeConversion == CustomFieldsTypeConversion.Stringify && (typeof value) != "string") {
118-
record.payload[key] = jsonStringifySafe(value);;
118+
record.payload[key] = jsonStringifySafe(value);
119119
} else {
120120
record.payload[key] = value;
121-
}
121+
}
122122
}
123123

124124
if ([CustomFieldsFormat.ApplicationLogging, CustomFieldsFormat.All].includes(customFieldsFormat)) {
@@ -131,7 +131,7 @@ export default class RecordFactory {
131131
}
132132
});
133133

134-
//writes custom fields in the correct order and correlates i to the place in registeredCustomFields
134+
// Write custom fields in the correct order and correlates i to the place in registeredCustomFields
135135
if (Object.keys(indexedCustomFields).length > 0) {
136136
let res: any = {};
137137
res.string = [];

src/test/acceptance-test/custom-fields.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe('Test custom fields', function () {
145145
log.logMessage("info", "test-message");
146146
});
147147

148-
it('logs custom fields as strings', function () {
148+
it('logs custom fields with their retained type', function () {
149149
expect(lastOutput).to.have.property('field-a', 42).that.is.a('number');
150150
expect(lastOutput).to.have.property('field-b', true).that.is.a('boolean');
151151
expect(lastOutput).to.have.property('field-c').that.deep.equals({"key":"value"})

0 commit comments

Comments
 (0)