@@ -185,7 +185,7 @@ describe('Formatters', () => {
185185 it ( 'when `logRecordOrder` is set, it orders the attributes in the log item' , ( ) => {
186186 // Prepare
187187 const formatter = new PowertoolsLogFormatter ( {
188- logRecordOrder : [ 'message' , 'timestamp' , 'serviceName' , 'environment '] ,
188+ logRecordOrder : [ 'message' , 'timestamp' , 'service ' ] ,
189189 } ) ;
190190 const additionalLogAttributes : LogAttributes = { } ;
191191
@@ -198,21 +198,19 @@ describe('Formatters', () => {
198198 const response = value . getAttributes ( ) ;
199199
200200 // 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+ } ) ;
216214 } ) ;
217215
218216 it ( 'when `logRecordOrder` is set, it orders the attributes in the log item taking `additionalLogAttributes` into consideration' , ( ) => {
@@ -222,8 +220,8 @@ describe('Formatters', () => {
222220 'message' ,
223221 'additional_key' ,
224222 'timestamp' ,
225- 'serviceName ' ,
226- 'environment ' ,
223+ 'level ' ,
224+ 'service ' ,
227225 ] ) ,
228226 } ) ;
229227 const additionalLogAttributes : LogAttributes = {
@@ -240,23 +238,21 @@ describe('Formatters', () => {
240238 const response = value . getAttributes ( ) ;
241239
242240 // 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+ } ) ;
260256 } ) ;
261257
262258 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', () => {
267263 'additional_key' ,
268264 'not_present' ,
269265 'timestamp' ,
270- 'serviceName' ,
271- 'environment' ,
266+ 'level' ,
272267 ] ,
273268 } ) ;
274269 const additionalLogAttributes : LogAttributes = {
@@ -284,22 +279,20 @@ describe('Formatters', () => {
284279 const response = value . getAttributes ( ) ;
285280
286281 // 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+ } ) ;
303296 } ) ;
304297
305298 it ( 'when logRecordOrder is not set, it will not order the attributes in the log item' , ( ) => {
@@ -318,22 +311,20 @@ describe('Formatters', () => {
318311 const response = value . getAttributes ( ) ;
319312
320313 // 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+ } ) ;
337328 } ) ;
338329
339330 // #region format errors
0 commit comments