Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const isDev = process.env.NODE_ENV === 'development'
- const eff = f => x => ((f(x), x))
- const noop = () => {}
- const pad = n => n < 10 ? '0' + n : n
- const fmtD = d => d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) +
- ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds())
- const now = () => fmtD(new Date())
- const info = tag => x => {
- console.log(`\x1b[34m${now()} ${tag}\x1b[0m`)
- console.dir(x, { colors: true })
- console.log()
- }
- const error = tag => e => {
- console.error(`\x1b[31m${now()} ${tag}\x1b[0m`)
- console.dir(e, { colors: true })
- console.log()
- }
- const trace = tag => eff(isDev ? info(tag) : noop)
- module.exports = { error, info, trace }
Add Comment
Please, Sign In to add comment