Skip to content

Instantly share code, notes, and snippets.

@theanam

theanam/logger.js

Created Apr 5, 2019
Embed
What would you like to do?
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
You can’t perform that action at this time.