File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed
Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,6 @@ function noop() {}
6060 * Consumers subscribe to diagnostics_channel events
6161 */
6262class LogConsumer {
63- #level;
6463 #levelValue;
6564
6665 constructor ( options = kEmptyObject ) {
@@ -168,11 +167,25 @@ class JSONConsumer extends LogConsumer {
168167 level : record . level ,
169168 time : record . time ,
170169 msg : record . msg ,
171- ...this . #fields,
172- ...record . bindings ,
173- ...record . fields ,
174170 } ;
175171
172+ // Merge fields in order: consumer fields -> bindings -> log fields
173+ // Using direct property assignment for better performance
174+ const consumerFields = this . #fields;
175+ for ( const key in consumerFields ) {
176+ logObj [ key ] = consumerFields [ key ] ;
177+ }
178+
179+ const bindings = record . bindings ;
180+ for ( const key in bindings ) {
181+ logObj [ key ] = bindings [ key ] ;
182+ }
183+
184+ const fields = record . fields ;
185+ for ( const key in fields ) {
186+ logObj [ key ] = fields [ key ] ;
187+ }
188+
176189 const json = JSONStringify ( logObj ) + '\n' ;
177190 this . #stream. write ( json ) ;
178191 }
@@ -270,10 +283,12 @@ class Logger {
270283 bindings ,
271284 ) ;
272285
273- return new Logger ( {
286+ const childLogger = new Logger ( {
274287 level : options . level || this . #level,
275288 bindings : mergedBindings ,
276289 } ) ;
290+
291+ return childLogger ;
277292 }
278293
279294 /**
You can’t perform that action at this time.
0 commit comments