diff --git a/examples/basic.js b/examples/basic.js index 8adffb11..6a42e531 100644 --- a/examples/basic.js +++ b/examples/basic.js @@ -4,6 +4,8 @@ consola.start('Starting build') consola.warn('Something is going to happen soon') +consola.log('Bla', 'Bla', 'Bla', 'Bla') + setTimeout(() => { consola.success('Build succeed in 10 seconds') consola.info('Some extra info is here') diff --git a/src/consola.js b/src/consola.js index 644e51f3..93d9112a 100644 --- a/src/consola.js +++ b/src/consola.js @@ -18,7 +18,7 @@ export default class Consola { } _createLogFn (defaults) { - return opts => { + return (opts, ...args) => { if (!opts) { return this } @@ -27,14 +27,17 @@ export default class Consola { date: new Date() }, defaults) + const argsStr = Array.from(args).map(String).join(' ') + if (typeof opts === 'string') { // String logObj.message = opts + logObj.additional = argsStr } else if (opts.stack) { // Error const [message, ...stack] = opts.stack.split('\n') logObj.message = message - logObj.additional = stack.map(s => s.trim()).join('\n') + logObj.additional = (argsStr.length ? argsStr + '\n' : '') + stack.map(s => s.trim()).join('\n') } else { // Object Object.assign(logObj, opts)