Created
April 25, 2018 19:52
-
-
Save jonathanborges/060fc1b17fbd05e89aa8113c9c8d2224 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ms = require('ms'); | |
const c = require('colors'); | |
class Debugger { | |
debug(description) { | |
let prevTime = this.prevTime; | |
let curr = +new Date(); | |
let milliseconds = curr - (prevTime || curr); | |
this.prevTime = curr; | |
let formatedMs = ms(milliseconds); | |
let outputAnsi = c.bold.green(description) + ' ' + c.green(formatedMs) + "\n"; | |
process.stderr.write(outputAnsi); | |
console.log("%c" + description + " %c" + formatedMs, 'font-weight:bold;color:green', 'color:green'); | |
} | |
} | |
function debug(description) { | |
let d = new Debugger(); | |
d.debug.call(this, description); | |
} | |
module.exports = debug; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment