@@ -185,7 +185,7 @@ describe('Formatters', () => {
185
185
it ( 'when `logRecordOrder` is set, it orders the attributes in the log item' , ( ) => {
186
186
// Prepare
187
187
const formatter = new PowertoolsLogFormatter ( {
188
- logRecordOrder : [ 'message' , 'timestamp' , 'serviceName' , 'environment '] ,
188
+ logRecordOrder : [ 'message' , 'timestamp' , 'service ' ] ,
189
189
} ) ;
190
190
const additionalLogAttributes : LogAttributes = { } ;
191
191
@@ -198,21 +198,19 @@ describe('Formatters', () => {
198
198
const response = value . getAttributes ( ) ;
199
199
200
200
// Assess
201
- expect ( JSON . stringify ( response ) ) . toEqual (
202
- JSON . stringify ( {
203
- message : 'This is a WARN log' ,
204
- timestamp : '2016-06-20T12:08:10.000Z' ,
205
- cold_start : true ,
206
- function_arn : 'arn:aws:lambda:eu-west-1:123456789012:function:Example' ,
207
- function_memory_size : '123' ,
208
- function_name : 'my-lambda-function' ,
209
- function_request_id : 'abcdefg123456789' ,
210
- level : 'WARN' ,
211
- sampling_rate : 0.25 ,
212
- service : 'hello-world' ,
213
- xray_trace_id : '1-5759e988-bd862e3fe1be46a994272793' ,
214
- } )
215
- ) ;
201
+ expect ( response ) . toStrictEqual ( {
202
+ message : 'This is a WARN log' ,
203
+ timestamp : '2016-06-20T12:08:10.000Z' ,
204
+ service : 'hello-world' ,
205
+ level : 'WARN' ,
206
+ cold_start : true ,
207
+ function_arn : 'arn:aws:lambda:eu-west-1:123456789012:function:Example' ,
208
+ function_memory_size : '123' ,
209
+ function_name : 'my-lambda-function' ,
210
+ function_request_id : 'abcdefg123456789' ,
211
+ sampling_rate : 0.25 ,
212
+ xray_trace_id : '1-5759e988-bd862e3fe1be46a994272793' ,
213
+ } ) ;
216
214
} ) ;
217
215
218
216
it ( 'when `logRecordOrder` is set, it orders the attributes in the log item taking `additionalLogAttributes` into consideration' , ( ) => {
@@ -222,8 +220,8 @@ describe('Formatters', () => {
222
220
'message' ,
223
221
'additional_key' ,
224
222
'timestamp' ,
225
- 'serviceName ' ,
226
- 'environment ' ,
223
+ 'level ' ,
224
+ 'service ' ,
227
225
] ) ,
228
226
} ) ;
229
227
const additionalLogAttributes : LogAttributes = {
@@ -240,23 +238,21 @@ describe('Formatters', () => {
240
238
const response = value . getAttributes ( ) ;
241
239
242
240
// Assess
243
- expect ( JSON . stringify ( response ) ) . toEqual (
244
- JSON . stringify ( {
245
- message : 'This is a WARN log' ,
246
- additional_key : 'additional_value' ,
247
- timestamp : '2016-06-20T12:08:10.000Z' ,
248
- cold_start : true ,
249
- function_arn : 'arn:aws:lambda:eu-west-1:123456789012:function:Example' ,
250
- function_memory_size : '123' ,
251
- function_name : 'my-lambda-function' ,
252
- function_request_id : 'abcdefg123456789' ,
253
- level : 'WARN' ,
254
- sampling_rate : 0.25 ,
255
- service : 'hello-world' ,
256
- xray_trace_id : '1-5759e988-bd862e3fe1be46a994272793' ,
257
- another_key : 'another_value' ,
258
- } )
259
- ) ;
241
+ expect ( response ) . toStrictEqual ( {
242
+ message : 'This is a WARN log' ,
243
+ additional_key : 'additional_value' ,
244
+ timestamp : '2016-06-20T12:08:10.000Z' ,
245
+ level : 'WARN' ,
246
+ service : 'hello-world' ,
247
+ cold_start : true ,
248
+ function_arn : 'arn:aws:lambda:eu-west-1:123456789012:function:Example' ,
249
+ function_memory_size : '123' ,
250
+ function_name : 'my-lambda-function' ,
251
+ function_request_id : 'abcdefg123456789' ,
252
+ sampling_rate : 0.25 ,
253
+ xray_trace_id : '1-5759e988-bd862e3fe1be46a994272793' ,
254
+ another_key : 'another_value' ,
255
+ } ) ;
260
256
} ) ;
261
257
262
258
it ( 'when `logRecordOrder` is set, even if a key does not exist in attributes, it orders the attributes correctly' , ( ) => {
@@ -267,8 +263,7 @@ describe('Formatters', () => {
267
263
'additional_key' ,
268
264
'not_present' ,
269
265
'timestamp' ,
270
- 'serviceName' ,
271
- 'environment' ,
266
+ 'level' ,
272
267
] ,
273
268
} ) ;
274
269
const additionalLogAttributes : LogAttributes = {
@@ -284,22 +279,20 @@ describe('Formatters', () => {
284
279
const response = value . getAttributes ( ) ;
285
280
286
281
// Assess
287
- expect ( JSON . stringify ( response ) ) . toEqual (
288
- JSON . stringify ( {
289
- message : 'This is a WARN log' ,
290
- additional_key : 'additional_value' ,
291
- timestamp : '2016-06-20T12:08:10.000Z' ,
292
- cold_start : true ,
293
- function_arn : 'arn:aws:lambda:eu-west-1:123456789012:function:Example' ,
294
- function_memory_size : '123' ,
295
- function_name : 'my-lambda-function' ,
296
- function_request_id : 'abcdefg123456789' ,
297
- level : 'WARN' ,
298
- sampling_rate : 0.25 ,
299
- service : 'hello-world' ,
300
- xray_trace_id : '1-5759e988-bd862e3fe1be46a994272793' ,
301
- } )
302
- ) ;
282
+ expect ( response ) . toStrictEqual ( {
283
+ message : 'This is a WARN log' ,
284
+ additional_key : 'additional_value' ,
285
+ timestamp : '2016-06-20T12:08:10.000Z' ,
286
+ level : 'WARN' ,
287
+ service : 'hello-world' ,
288
+ cold_start : true ,
289
+ function_arn : 'arn:aws:lambda:eu-west-1:123456789012:function:Example' ,
290
+ function_memory_size : '123' ,
291
+ function_name : 'my-lambda-function' ,
292
+ function_request_id : 'abcdefg123456789' ,
293
+ sampling_rate : 0.25 ,
294
+ xray_trace_id : '1-5759e988-bd862e3fe1be46a994272793' ,
295
+ } ) ;
303
296
} ) ;
304
297
305
298
it ( 'when logRecordOrder is not set, it will not order the attributes in the log item' , ( ) => {
@@ -318,22 +311,20 @@ describe('Formatters', () => {
318
311
const response = value . getAttributes ( ) ;
319
312
320
313
// Assess
321
- expect ( JSON . stringify ( response ) ) . toEqual (
322
- JSON . stringify ( {
323
- cold_start : true ,
324
- function_arn : 'arn:aws:lambda:eu-west-1:123456789012:function:Example' ,
325
- function_memory_size : '123' ,
326
- function_name : 'my-lambda-function' ,
327
- function_request_id : 'abcdefg123456789' ,
328
- level : 'WARN' ,
329
- message : 'This is a WARN log' ,
330
- sampling_rate : 0.25 ,
331
- service : 'hello-world' ,
332
- timestamp : '2016-06-20T12:08:10.000Z' ,
333
- xray_trace_id : '1-5759e988-bd862e3fe1be46a994272793' ,
334
- additional_key : 'additional_value' ,
335
- } )
336
- ) ;
314
+ expect ( response ) . toStrictEqual ( {
315
+ level : 'WARN' ,
316
+ message : 'This is a WARN log' ,
317
+ timestamp : '2016-06-20T12:08:10.000Z' ,
318
+ service : 'hello-world' ,
319
+ cold_start : true ,
320
+ function_arn : 'arn:aws:lambda:eu-west-1:123456789012:function:Example' ,
321
+ function_memory_size : '123' ,
322
+ function_name : 'my-lambda-function' ,
323
+ function_request_id : 'abcdefg123456789' ,
324
+ sampling_rate : 0.25 ,
325
+ xray_trace_id : '1-5759e988-bd862e3fe1be46a994272793' ,
326
+ additional_key : 'additional_value' ,
327
+ } ) ;
337
328
} ) ;
338
329
339
330
// #region format errors
0 commit comments