2121
2222'use strict' ; 
2323
24+ const  {  trace }  =  internalBinding ( 'trace_events' ) ; 
2425const  { 
2526  isStackOverflowError, 
2627  codes : { 
@@ -37,6 +38,12 @@ const {
3738}  =  util . types ; 
3839const  kCounts  =  Symbol ( 'counts' ) ; 
3940
41+ const  kTraceConsoleCategory  =  'node,node.console' ; 
42+ const  kTraceCount  =  'C' . charCodeAt ( 0 ) ; 
43+ const  kTraceBegin  =  'b' . charCodeAt ( 0 ) ; 
44+ const  kTraceEnd  =  'e' . charCodeAt ( 0 ) ; 
45+ const  kTraceInstant  =  'n' . charCodeAt ( 0 ) ; 
46+ 
4047const  { 
4148  keys : ObjectKeys , 
4249  values : ObjectValues , 
@@ -232,13 +239,15 @@ Console.prototype.time = function time(label = 'default') {
232239    process . emitWarning ( `Label '${ label }  ' already exists for console.time()` ) ; 
233240    return ; 
234241  } 
242+   trace ( kTraceBegin ,  kTraceConsoleCategory ,  `time::${ label }  ` ,  0 ) ; 
235243  this . _times . set ( label ,  process . hrtime ( ) ) ; 
236244} ; 
237245
238246Console . prototype . timeEnd  =  function  timeEnd ( label  =  'default' )  { 
239247  // Coerces everything other than Symbol to a string 
240248  label  =  `${ label }  ` ; 
241249  const  hasWarned  =  timeLogImpl ( this ,  'timeEnd' ,  label ) ; 
250+   trace ( kTraceEnd ,  kTraceConsoleCategory ,  `time::${ label }  ` ,  0 ) ; 
242251  if  ( ! hasWarned )  { 
243252    this . _times . delete ( label ) ; 
244253  } 
@@ -248,6 +257,7 @@ Console.prototype.timeLog = function timeLog(label, ...data) {
248257  // Coerces everything other than Symbol to a string 
249258  label  =  `${ label }  ` ; 
250259  timeLogImpl ( this ,  'timeLog' ,  label ,  data ) ; 
260+   trace ( kTraceInstant ,  kTraceConsoleCategory ,  `time::${ label }  ` ,  0 ) ; 
251261} ; 
252262
253263// Returns true if label was not found 
@@ -308,6 +318,7 @@ Console.prototype.count = function count(label = 'default') {
308318  else 
309319    count ++ ; 
310320  counts . set ( label ,  count ) ; 
321+   trace ( kTraceCount ,  kTraceConsoleCategory ,  `count::${ label }  ` ,  0 ,  count ) ; 
311322  this . log ( `${ label }  : ${ count }  ` ) ; 
312323} ; 
313324
@@ -318,7 +329,7 @@ Console.prototype.countReset = function countReset(label = 'default') {
318329    process . emitWarning ( `Count for '${ label }  ' does not exist` ) ; 
319330    return ; 
320331  } 
321- 
332+    trace ( kTraceCount ,   kTraceConsoleCategory ,   `count:: ${ label } ` ,   0 ,   0 ) ; 
322333  counts . delete ( `${ label }  ` ) ; 
323334} ; 
324335
0 commit comments