diff options
Diffstat (limited to 'node_modules/glogg/index.js')
-rw-r--r-- | node_modules/glogg/index.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/node_modules/glogg/index.js b/node_modules/glogg/index.js new file mode 100644 index 000000000..9d0b16d7e --- /dev/null +++ b/node_modules/glogg/index.js @@ -0,0 +1,34 @@ +'use strict'; + +var format = require('util').format; + +var sparkles = require('sparkles'); + +var levels = [ + 'debug', + 'info', + 'warn', + 'error' +]; + +function getLogger(namespace){ + var logger = sparkles(namespace); + + levels.forEach(function(level){ + logger[level] = makeLogLevel(level); + }); + + return logger; +} + +function makeLogLevel(level){ + return function(msg){ + if(typeof msg === 'string'){ + msg = format.apply(null, arguments); + } + + this.emit(level, msg); + }; +} + +module.exports = getLogger; |