File tree 1 file changed +19
-1
lines changed
packages/logger/src/formatter
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,25 @@ class PowertoolsLogFormatter extends LogFormatter {
35
35
timestamp : this . formatTimestamp ( attributes . timestamp ) ,
36
36
xray_trace_id : attributes . xRayTraceId ,
37
37
} ;
38
- const powertoolsLogItem = new LogItem ( { attributes : baseAttributes } ) ;
38
+
39
+ const orderedAttributes = { } as PowertoolsLog ;
40
+
41
+ // If logRecordOrder is set, order the attributes in the log item
42
+ this . logRecordOrder ?. forEach ( ( key ) => {
43
+ if ( key in baseAttributes ) {
44
+ orderedAttributes [ key ] = baseAttributes [ key ] ;
45
+ delete baseAttributes [ key ] ;
46
+ }
47
+ } ) ;
48
+
49
+ // Merge the ordered attributes with the rest of the attributes
50
+ const powertoolsLogItem = new LogItem ( {
51
+ attributes : {
52
+ ...orderedAttributes ,
53
+ ...baseAttributes ,
54
+ } ,
55
+ } ) ;
56
+
39
57
powertoolsLogItem . addAttributes ( additionalLogAttributes ) ;
40
58
41
59
return powertoolsLogItem ;
You can’t perform that action at this time.
0 commit comments