mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00
Revert "console: colorize console error and warn"
This reverts commit a833c9e0be
.
PR-URL: https://github.com/nodejs/node/pull/54677
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
e8127db032
commit
2d77ba5d30
5 changed files with 12 additions and 27 deletions
|
@ -8,7 +8,6 @@ const {
|
|||
ArrayIsArray,
|
||||
ArrayPrototypeForEach,
|
||||
ArrayPrototypePush,
|
||||
ArrayPrototypeSome,
|
||||
ArrayPrototypeUnshift,
|
||||
Boolean,
|
||||
ErrorCaptureStackTrace,
|
||||
|
@ -60,7 +59,6 @@ const {
|
|||
const {
|
||||
CHAR_UPPERCASE_C: kTraceCount,
|
||||
} = require('internal/constants');
|
||||
const { styleText } = require('util');
|
||||
const kCounts = Symbol('counts');
|
||||
const { time, timeLog, timeEnd, kNone } = require('internal/util/debuglog');
|
||||
|
||||
|
@ -264,7 +262,7 @@ ObjectDefineProperties(Console.prototype, {
|
|||
[kWriteToConsole]: {
|
||||
__proto__: null,
|
||||
...consolePropAttributes,
|
||||
value: function(streamSymbol, string, color = '') {
|
||||
value: function(streamSymbol, string) {
|
||||
const ignoreErrors = this._ignoreErrors;
|
||||
const groupIndent = internalIndentationMap.get(this) || '';
|
||||
|
||||
|
@ -279,11 +277,6 @@ ObjectDefineProperties(Console.prototype, {
|
|||
}
|
||||
string = groupIndent + string;
|
||||
}
|
||||
|
||||
if (color) {
|
||||
string = styleText(color, string);
|
||||
}
|
||||
|
||||
string += '\n';
|
||||
|
||||
if (ignoreErrors === false) return stream.write(string);
|
||||
|
@ -382,15 +375,12 @@ const consoleMethods = {
|
|||
log(...args) {
|
||||
this[kWriteToConsole](kUseStdout, this[kFormatForStdout](args));
|
||||
},
|
||||
|
||||
|
||||
warn(...args) {
|
||||
const color = (shouldColorize(args) && 'yellow') || '';
|
||||
this[kWriteToConsole](kUseStderr, this[kFormatForStderr](args), color);
|
||||
this[kWriteToConsole](kUseStderr, this[kFormatForStderr](args));
|
||||
},
|
||||
|
||||
error(...args) {
|
||||
const color = (shouldColorize(args) && 'red') || '';
|
||||
this[kWriteToConsole](kUseStderr, this[kFormatForStderr](args), color);
|
||||
},
|
||||
|
||||
dir(object, options) {
|
||||
this[kWriteToConsole](kUseStdout, inspect(object, {
|
||||
|
@ -621,12 +611,6 @@ const iterKey = '(iteration index)';
|
|||
|
||||
const isArray = (v) => ArrayIsArray(v) || isTypedArray(v) || isBuffer(v);
|
||||
|
||||
// TODO: remove string type check once the styleText supports objects
|
||||
// Return true if all args are type string
|
||||
const shouldColorize = (args) => {
|
||||
return lazyUtilColors().hasColors && !ArrayPrototypeSome(args, (arg) => typeof arg !== 'string');
|
||||
};
|
||||
|
||||
function noop() {}
|
||||
|
||||
for (const method of ReflectOwnKeys(consoleMethods))
|
||||
|
@ -635,6 +619,7 @@ for (const method of ReflectOwnKeys(consoleMethods))
|
|||
Console.prototype.debug = Console.prototype.log;
|
||||
Console.prototype.info = Console.prototype.log;
|
||||
Console.prototype.dirxml = Console.prototype.log;
|
||||
Console.prototype.error = Console.prototype.warn;
|
||||
Console.prototype.groupCollapsed = Console.prototype.group;
|
||||
|
||||
function initializeGlobalConsole(globalConsole) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue