Comparing version 1.3.0 to 1.4.0
@@ -5,2 +5,13 @@ # Change Log | ||
<a name="1.4.0"></a> | ||
# [1.4.0](https://github.com/nuxt/consola/compare/v1.3.0...v1.4.0) (2018-05-27) | ||
### Features | ||
* support custom additional style ([#18](https://github.com/nuxt/consola/issues/18)) ([7a750bf](https://github.com/nuxt/consola/commit/7a750bf)) | ||
* **fancy:** support icon field ([0123bed](https://github.com/nuxt/consola/commit/0123bed)) | ||
<a name="1.3.0"></a> | ||
@@ -7,0 +18,0 @@ # [1.3.0](https://github.com/nuxt/consola/compare/v1.2.0...v1.3.0) (2018-04-15) |
@@ -300,3 +300,3 @@ 'use strict'; | ||
var color = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'blue'; | ||
var icon = ICONS[type] || ICONS.default; | ||
var icon = arguments.length > 2 ? arguments[2] : undefined; | ||
return chalk[color]("".concat(icon, " ").concat(type.toLowerCase())) + ' '; | ||
@@ -322,6 +322,8 @@ } | ||
var icon = logObj.icon || ICONS[type] || ICONS.default; | ||
if (logObj.badge) { | ||
this.stream.write('\n\n' + this.formatBadge(logObj.type, logObj.color) + message + '\n\n'); | ||
this.stream.write('\n\n' + this.formatBadge(logObj.type, logObj.color, icon) + message + '\n\n'); | ||
} else { | ||
this.stream.write(this.formatTag(logObj.type, logObj.color) + message + '\n'); | ||
this.stream.write(this.formatTag(logObj.type, logObj.color, icon) + message + '\n'); | ||
} | ||
@@ -333,3 +335,3 @@ | ||
}).join('\n'); | ||
this.stream.write(chalk.grey(lines) + '\n'); | ||
this.stream.write(chalk[logObj.additionalStyle || 'grey'](lines) + '\n'); | ||
} | ||
@@ -336,0 +338,0 @@ } |
{ | ||
"name": "consola", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Elegant Console Logger", | ||
@@ -5,0 +5,0 @@ "main": "./dist/consola.cjs.js", |
@@ -161,2 +161,4 @@ # Consola | ||
- `additional` | ||
- `additionalStyle` (By default: `grey`) | ||
- `icon` (Default depends on log type) | ||
@@ -163,0 +165,0 @@ ## Integrations |
@@ -25,8 +25,7 @@ import chalk from 'chalk' | ||
formatBadge (type, color = 'blue') { | ||
formatBadge (type, color = 'blue', icon) { | ||
return chalk['bg' + startCase(color)].black(` ${type.toUpperCase()} `) + ' ' | ||
} | ||
formatTag (type, color = 'blue') { | ||
const icon = ICONS[type] || ICONS.default | ||
formatTag (type, color = 'blue', icon) { | ||
return chalk[color](`${icon} ${type.toLowerCase()}`) + ' ' | ||
@@ -52,6 +51,8 @@ } | ||
const icon = logObj.icon || ICONS[type] || ICONS.default | ||
if (logObj.badge) { | ||
this.stream.write('\n\n' + this.formatBadge(logObj.type, logObj.color) + message + '\n\n') | ||
this.stream.write('\n\n' + this.formatBadge(logObj.type, logObj.color, icon) + message + '\n\n') | ||
} else { | ||
this.stream.write(this.formatTag(logObj.type, logObj.color) + message + '\n') | ||
this.stream.write(this.formatTag(logObj.type, logObj.color, icon) + message + '\n') | ||
} | ||
@@ -61,5 +62,5 @@ | ||
const lines = logObj.additional.split('\n').map(s => ' ' + s).join('\n') | ||
this.stream.write(chalk.grey(lines) + '\n') | ||
this.stream.write(chalk[logObj.additionalStyle || 'grey'](lines) + '\n') | ||
} | ||
} | ||
} |
23307
600
185