GeezerVison is showing github.com — Revert "console: colorize console error and warn" · nodejs/node@3ba2e7b
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/console/constructor.js +5-20Lines changed: 5 additions & 20 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 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) { | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-repl.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -785,7 +785,6 @@ const errorTests = [ | 785 | 785 | 'Object [console] {', | 786 | 786 | ' log: [Function: log],', | 787 | 787 | ' warn: [Function: warn],', | 788 | | - ' error: [Function: error],', | 789 | 788 | ' dir: [Function: dir],', | 790 | 789 | ' time: [Function: time],', | 791 | 790 | ' timeEnd: [Function: timeEnd],', | @@ -801,6 +800,7 @@ const errorTests = [ | 801 | 800 | / {2}debug: \[Function: (debug|log)],/, | 802 | 801 | / {2}info: \[Function: (info|log)],/, | 803 | 802 | / {2}dirxml: \[Function: (dirxml|log)],/, | | 803 | + / {2}error: \[Function: (error|warn)],/, | 804 | 804 | / {2}groupCollapsed: \[Function: (groupCollapsed|group)],/, | 805 | 805 | / {2}Console: \[Function: Console],?/, | 806 | 806 | ...process.features.inspector ? [ | |
Collapse file Copy file name to clipboard +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 |
| 2 | | -*(node:*) Warning: The 'NODE_DISABLE_COLORS' env is ignored due to the 'FORCE_COLOR' env being set. | 3 | | -(Use `* --trace-warnings ...` to show where the warning was created)* | | 2 | +(node:*) Warning: The 'NODE_DISABLE_COLORS' env is ignored due to the 'FORCE_COLOR' env being set. | | 3 | +(Use `* --trace-warnings ...` to show where the warning was created) |
Collapse file Copy file name to clipboard +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 |
| 2 | | -*(node:*) Warning: The 'NODE_DISABLE_COLORS' and 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set. | 3 | | -(Use `* --trace-warnings ...` to show where the warning was created)* | | 2 | +(node:*) Warning: The 'NODE_DISABLE_COLORS' and 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set. | | 3 | +(Use `* --trace-warnings ...` to show where the warning was created) |
Collapse file Copy file name to clipboard +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -*(node:*) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set. | 2 | | -(Use `* --trace-warnings ...` to show where the warning was created)* | | 1 | +(node:*) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set. | | 2 | +(Use `* --trace-warnings ...` to show where the warning was created) |
|