Created
April 5, 2019 17:53
-
-
Save theanam/4f36e2e0bd847b9ca2f6abb4a1e4cc05 to your computer and use it in GitHub Desktop.
Stdout logs on Steroids
This file contains hidden or 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 moment = require('moment'); | |
const colors = { | |
"green" :"\x1b[32m", | |
"yellow":"\x1b[33m%s\x1b[0m", | |
"red":"\x1b[31m", | |
"cyan":"\x1b[36m", | |
"blue":"\x1b[34m", | |
"default":"" | |
} | |
module.exports = function (message,color="default"){ | |
// Logs in BD time UTC+6 | |
let tm = moment().utc().add(6,'hours').format(`DDMMMYY_h:mA`); | |
console.log(colors[color.toLowerCase()]||"",`[${tm}]${message}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment