UNPKG

clown

Version:
47 lines (38 loc) 1.22 kB
var log = module.exports = require('npmlog'); log.raw = console.log; // change log.heading = 'clown'; log.addLevel('help', 2000, {fg: 'blue', bg: 'grey'}, 'help'); log.pkgcloud = function logPkgcloud(client) { log.silly('log', 'Adding pkgcloud hooks'); client.on('log::*', function(message, obj) { var lvl = this.event.split('::').pop(); if (lvl === 'trace') lvl = 'silly'; var l = (log[lvl] || log.verbose).bind(log, 'pkgcloud'); if (obj) { l(message + '(%j)', obj); } else { l(message); } }); }; log.argv = function(argv) { if (argv.level) { log.level = argv.level; } log.silly('log', 'Use logging level: %s', argv.level); }; log.hello = function hello() { log.info('hello', 'Clown (computing with pkgcloud)'); log.info('hello', 'Programmed entirely in @jesusabdullah\'s apartment'); log.info('hello', 'Copyright 2014'); }; process.on('uncaughtException', function(err) { log.error('fatal', 'FLAGRANT ERROR?!'); (err.stack || '').split('\n').forEach(function(l) { log.error('fatal', l); }); Object.keys(err).forEach(function(k) { log.error('fatal', '* %j', err[k]); }); log.info('bye', 'Better luck next time!'); process.exit(1); });