Skip to content

Commit c29cb9e

Browse files
committed
cleanup and added more tests
1 parent e455e8c commit c29cb9e

File tree

5 files changed

+339
-266
lines changed

5 files changed

+339
-266
lines changed

lib/internal/console/constructor.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ const kCounts = Symbol('counts');
6363

6464
const kTraceConsoleCategory = 'node,node.console';
6565

66-
let _traceTimer;
66+
let _debugLog;
6767
/**
68-
* @returns {import('internal/util/trace_timer')}
68+
* @returns {import('internal/util/debuglog')}
6969
*/
70-
function lazyTraceTimer() {
71-
if (_traceTimer) {
72-
return _traceTimer;
70+
function lazyDebugLog() {
71+
if (_debugLog) {
72+
return _debugLog;
7373
}
7474

75-
_traceTimer = require('internal/util/trace_timer');
76-
return _traceTimer;
75+
_debugLog = require('internal/util/debuglog');
76+
return _debugLog;
7777
}
7878

7979
const kMaxGroupIndentation = 1000;
@@ -405,21 +405,24 @@ const consoleMethods = {
405405
},
406406

407407
time(label = 'default') {
408-
lazyTraceTimer().time(this._times, kTraceConsoleCategory, 'console.time()', label, `time::${label}`);
408+
lazyDebugLog()
409+
.time(this._times, kTraceConsoleCategory, 'console.time()', lazyDebugLog().kNone, label, `time::${label}`);
409410
},
410411

411412
timeEnd(label = 'default') {
412413
if (this[kInternalTimeLogImpl] === undefined)
413414
this[kInternalTimeLogImpl] = FunctionPrototypeBind(timeLogImpl, this);
414415

415-
lazyTraceTimer().timeEnd(this._times, kTraceConsoleCategory, 'console.timeEnd()', this[kInternalTimeLogImpl], label, `time::${label}`);
416+
lazyDebugLog()
417+
.timeEnd(this._times, kTraceConsoleCategory, 'console.timeEnd()', lazyDebugLog().kNone, this[kInternalTimeLogImpl], label, `time::${label}`);
416418
},
417419

418420
timeLog(label = 'default', ...data) {
419421
if (this[kInternalTimeLogImpl] === undefined)
420422
this[kInternalTimeLogImpl] = FunctionPrototypeBind(timeLogImpl, this);
421423

422-
lazyTraceTimer().timeLog(this._times, kTraceConsoleCategory, 'console.timeLog()', this[kInternalTimeLogImpl], label, `time::${label}`, data);
424+
lazyDebugLog()
425+
.timeLog(this._times, kTraceConsoleCategory, 'console.timeLog()', lazyDebugLog().kNone, this[kInternalTimeLogImpl], label, `time::${label}`, data);
423426
},
424427

425428
trace: function trace(...args) {

0 commit comments

Comments
 (0)