Skip to content

Instantly share code, notes, and snippets.

@Vayvala
Created January 29, 2016 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vayvala/4b1880f9c92972c912a3 to your computer and use it in GitHub Desktop.
Save Vayvala/4b1880f9c92972c912a3 to your computer and use it in GitHub Desktop.
'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