@@ -273,7 +273,7 @@ ObjectDefineProperties(Console.prototype, {
273273 [ kWriteToConsole ] : {
274274 __proto__ : null ,
275275 ...consolePropAttributes ,
276- value : function ( streamSymbol , string ) {
276+ value : function ( streamSymbol , string , color ) {
277277 const ignoreErrors = this . _ignoreErrors ;
278278 const groupIndent = this [ kGroupIndent ] ;
279279
@@ -288,6 +288,11 @@ ObjectDefineProperties(Console.prototype, {
288288 }
289289 string = groupIndent + string ;
290290 }
291+
292+ if ( color && lazyUtilColors ( ) . hasColors ) {
293+ string = `${ color } ${ string } ${ lazyUtilColors ( ) . clear } ` ;
294+ }
295+
291296 string += '\n' ;
292297
293298 if ( ignoreErrors === false ) return stream . write ( string ) ;
@@ -381,9 +386,14 @@ const consoleMethods = {
381386
382387
383388 warn ( ...args ) {
384- this [ kWriteToConsole ] ( kUseStderr , this [ kFormatForStderr ] ( args ) ) ;
389+ const color = typeof args === 'string' ? lazyUtilColors ( ) . yellow : null ;
390+ this [ kWriteToConsole ] ( kUseStderr , this [ kFormatForStderr ] ( args ) , color ) ;
385391 } ,
386392
393+ error ( ...args ) {
394+ const color = typeof args === 'string' ? lazyUtilColors ( ) . red : null ;
395+ this [ kWriteToConsole ] ( kUseStderr , this [ kFormatForStderr ] ( args ) , color ) ;
396+ } ,
387397
388398 dir ( object , options ) {
389399 this [ kWriteToConsole ] ( kUseStdout , inspect ( object , {
@@ -689,7 +699,6 @@ for (const method of ReflectOwnKeys(consoleMethods))
689699Console . prototype . debug = Console . prototype . log ;
690700Console . prototype . info = Console . prototype . log ;
691701Console . prototype . dirxml = Console . prototype . log ;
692- Console . prototype . error = Console . prototype . warn ;
693702Console . prototype . groupCollapsed = Console . prototype . group ;
694703
695704function initializeGlobalConsole ( globalConsole ) {
0 commit comments