Created
January 29, 2016 12:04
-
-
Save Vayvala/4b1880f9c92972c912a3 to your computer and use it in GitHub Desktop.
This file contains 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
'use strict'; | |
const colors = require('colors/safe'); | |
const debug = require('debug'); | |
const _ = require('lodash'); | |
const debugLinks = {}; | |
const categories = [ | |
'cache', | |
'core', | |
'http', | |
'mongodb', | |
'routing', | |
'auth' | |
]; | |
_.each(categories, (category) => { | |
debugLinks[category] = debug(category); | |
exports[category] = (msg, type) => { | |
return logger({ | |
msg: msg, | |
type: type, | |
category: category | |
}); | |
}; | |
}); | |
function logger(req) { | |
switch (req.type) { | |
case 'error': | |
debugLinks[req.category](colors.red(req.msg)); | |
break; | |
case 'warning': | |
debugLinks[req.category](colors.yellow(req.msg)); | |
break; | |
default: | |
debugLinks[req.category](req.msg); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment