8
8
ArrayIsArray,
9
9
ArrayPrototypeForEach,
10
10
ArrayPrototypePush,
11
- ArrayPrototypeSome,
12
11
ArrayPrototypeUnshift,
13
12
Boolean,
14
13
ErrorCaptureStackTrace,
@@ -68,7 +67,6 @@ const {
68
67
CHAR_LOWERCASE_N : kTraceInstant ,
69
68
CHAR_UPPERCASE_C : kTraceCount ,
70
69
} = require ( 'internal/constants' ) ;
71
- const { styleText } = require ( 'util' ) ;
72
70
const kCounts = Symbol ( 'counts' ) ;
73
71
74
72
const kTraceConsoleCategory = 'node,node.console' ;
@@ -274,7 +272,7 @@ ObjectDefineProperties(Console.prototype, {
274
272
[ kWriteToConsole ] : {
275
273
__proto__ : null ,
276
274
...consolePropAttributes ,
277
- value : function ( streamSymbol , string , color = '' ) {
275
+ value : function ( streamSymbol , string ) {
278
276
const ignoreErrors = this . _ignoreErrors ;
279
277
const groupIndent = this [ kGroupIndent ] ;
280
278
@@ -289,11 +287,6 @@ ObjectDefineProperties(Console.prototype, {
289
287
}
290
288
string = groupIndent + string ;
291
289
}
292
-
293
- if ( color ) {
294
- string = styleText ( color , string ) ;
295
- }
296
-
297
290
string += '\n' ;
298
291
299
292
if ( ignoreErrors === false ) return stream . write ( string ) ;
@@ -384,15 +377,12 @@ const consoleMethods = {
384
377
log ( ...args ) {
385
378
this [ kWriteToConsole ] ( kUseStdout , this [ kFormatForStdout ] ( args ) ) ;
386
379
} ,
380
+
381
+
387
382
warn ( ...args ) {
388
- const color = ( shouldColorize ( args ) && 'yellow' ) || '' ;
389
- this [ kWriteToConsole ] ( kUseStderr , this [ kFormatForStderr ] ( args ) , color ) ;
383
+ this [ kWriteToConsole ] ( kUseStderr , this [ kFormatForStderr ] ( args ) ) ;
390
384
} ,
391
385
392
- error ( ...args ) {
393
- const color = ( shouldColorize ( args ) && 'red' ) || '' ;
394
- this [ kWriteToConsole ] ( kUseStderr , this [ kFormatForStderr ] ( args ) , color ) ;
395
- } ,
396
386
397
387
dir ( object , options ) {
398
388
this [ kWriteToConsole ] ( kUseStdout , inspect ( object , {
@@ -685,12 +675,6 @@ const iterKey = '(iteration index)';
685
675
686
676
const isArray = ( v ) => ArrayIsArray ( v ) || isTypedArray ( v ) || isBuffer ( v ) ;
687
677
688
- // TODO: remove string type check once the styleText supports objects
689
- // Return true if all args are type string
690
- const shouldColorize = ( args ) => {
691
- return lazyUtilColors ( ) . hasColors && ! ArrayPrototypeSome ( args , ( arg ) => typeof arg !== 'string' ) ;
692
- } ;
693
-
694
678
function noop ( ) { }
695
679
696
680
for ( const method of ReflectOwnKeys ( consoleMethods ) )
@@ -699,6 +683,7 @@ for (const method of ReflectOwnKeys(consoleMethods))
699
683
Console . prototype . debug = Console . prototype . log ;
700
684
Console . prototype . info = Console . prototype . log ;
701
685
Console . prototype . dirxml = Console . prototype . log ;
686
+ Console . prototype . error = Console . prototype . warn ;
702
687
Console . prototype . groupCollapsed = Console . prototype . group ;
703
688
704
689
function initializeGlobalConsole ( globalConsole ) {
0 commit comments