Skip to content

Instantly share code, notes, and snippets.

@theanam
Created April 5, 2019 17:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theanam/4f36e2e0bd847b9ca2f6abb4a1e4cc05 to your computer and use it in GitHub Desktop.
Save theanam/4f36e2e0bd847b9ca2f6abb4a1e4cc05 to your computer and use it in GitHub Desktop.
Stdout logs on Steroids
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