Skip to content

Commit

Permalink
fix: return earlier on not displaying levels
Browse files Browse the repository at this point in the history
  • Loading branch information
pimlie committed Oct 11, 2018
1 parent 7af5ed5 commit cfdcf04
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/consola.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export default class Consola {

_createLogFn (defaults) {
function fnLog () {
if (defaults.level > this.level) {
return false
}

// Construct a new log object
const logObj = Object.assign({
date: new Date(),
Expand Down Expand Up @@ -100,13 +104,19 @@ export default class Consola {
}

function fnSync () {
const logObj = fnLog.apply(undefined, arguments)
this._log(logObj)
const logObj = fnLog.apply(this, arguments)
if (logObj !== false) {
this._log(logObj)
}
}

function fnAsync (...args) {
const logObj = fnLog.apply(undefined, arguments)
return this._log(logObj)
const logObj = fnLog.apply(this, arguments)
if (logObj === false) {
return Promise.resolve()
} else {
return this._log(logObj)
}
}

// Bind function to instance of Consola
Expand Down Expand Up @@ -144,10 +154,6 @@ export default class Consola {
}

_log (logObj) {
if (logObj.level > this.level) {
return
}

const promises = []
for (const reporter of this.reporters) {
const promise = reporter.log(logObj, this.async)
Expand Down

0 comments on commit cfdcf04

Please sign in to comment.