From 5c694afd03b736fa56f4186b05181b9059c5a10e Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 2 Nov 2018 21:44:42 +0330 Subject: [PATCH] don't seperate additional part --- src/reporters/basic.js | 19 +++++-------------- src/reporters/fancy.js | 12 ++++++++---- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/reporters/basic.js b/src/reporters/basic.js index e4a4aa2..84ce1e2 100644 --- a/src/reporters/basic.js +++ b/src/reporters/basic.js @@ -26,18 +26,10 @@ export default class BasicReporter { return arg }) - let formattedArgs - if (util.formatWithOptions) { - formattedArgs = util.formatWithOptions({ colors: true }, ..._args) // Node >= 10 + if (typeof util.formatWithOptions === 'function') { + return util.formatWithOptions({ colors: true }, ..._args) // Node >= 10 } else { - formattedArgs = util.format(..._args) - } - - const [ message, ...more ] = formattedArgs.split('\n') - - return { - message, - additional: more.join('\n') + return util.format(..._args) } } @@ -50,7 +42,7 @@ export default class BasicReporter { } formatLogObj (logObj) { - const { message, additional } = this.formatArgs(logObj.args) + const message = this.formatArgs(logObj.args) const date = this.formatDate(logObj.date) const type = logObj.type.toUpperCase() @@ -59,8 +51,7 @@ export default class BasicReporter { bracket(date), bracket(logObj.tag), bracket(type), - message, - additional ? ('\n' + additional) : '' + message ]) } diff --git a/src/reporters/fancy.js b/src/reporters/fancy.js index a49e8b0..578f7fc 100644 --- a/src/reporters/fancy.js +++ b/src/reporters/fancy.js @@ -26,7 +26,11 @@ export default class FancyReporter extends BasicReporter { } formatStack (stack) { - return ' at ' + parseStack(stack).join(' ↲\n at ') + return ' at ' + parseStack(stack) + .map(line => { + return line + }) + .join(' ↲\n at ') } typeColor (type, level) { @@ -47,7 +51,7 @@ export default class FancyReporter extends BasicReporter { } formatLogObj (logObj, { width }) { - const { message, additional } = this.formatArgs(logObj.args) + const [ message, ...additional ] = this.formatArgs(logObj.args).split('\n') const isBadge = logObj.badge || logObj.level < 2 @@ -66,8 +70,8 @@ export default class FancyReporter extends BasicReporter { let line = space > 0 ? (left + ' '.repeat(space) + right) : left - line += additional - ? secondaryColor('\n' + additional) + line += additional.length + ? '\n' + additional.join('\n') : '' return isBadge ? '\n' + line + '\n' : line