Skip to content

Commit

Permalink
feat: showType option
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 9, 2018
1 parent 38a4729 commit ed294e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/reporters/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export default class BasicReporter {
constructor (options) {
this.options = Object.assign({
stream: process.stdout,
tagAlignment: 'left'
alignment: 'left',
showType: false
}, options)
}

Expand Down Expand Up @@ -71,13 +72,11 @@ export default class BasicReporter {
const fields = this.getFields(logObj)

// Print date
if (fields.type.length) {
this.write((`[${align(this.options.tagAlignment, fields.date, 8)}] `))
}
this.write((`[${align(this.options.alignment, fields.date, 8)}] `))

// Print type
if (fields.type.length) {
this.write((`[${align(this.options.tagAlignment, fields.type.toUpperCase(), 7)}] `))
this.write((`[${align(this.options.alignment, fields.type.toUpperCase(), 7)}] `))
}

// Print tag
Expand Down
10 changes: 7 additions & 3 deletions src/reporters/fancy.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ export default class FancyReporter extends BasicReporter {
}

// Print type
const type = align(this.options.tagAlignment, fields.type.toUpperCase(), 7)
const type = align(this.options.alignment, fields.type.toUpperCase(), 7)
if (logObj.badge) {
this.write('\n' + chalkBgColor(logObj.color).black(` ${type} `) + ' ')
} else if (fields.type !== 'log') {
const icon = logObj.icon || ICONS[fields.type] || ICONS.default
this.write(chalkColor(logObj.color)(`${icon} ${type} `))
if (this.showType) {
this.write(chalkColor(logObj.color)(`${icon} ${type} `))
} else {
this.write(chalkColor(logObj.color)(`${icon} `))
}
}

// Print tag
Expand All @@ -65,7 +69,7 @@ export default class FancyReporter extends BasicReporter {

// Print message
if (fields.message.length) {
this.write(fields.message)
this.write(chalkColor(logObj.color)(fields.message))
}

// Badge additional line
Expand Down

0 comments on commit ed294e4

Please sign in to comment.