diff --git a/index.js b/index.js new file mode 100644 index 0000000..9d0b16d --- /dev/null +++ b/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; diff --git a/package.json b/package.json new file mode 100644 index 0000000..5316095 --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "name": "glogg", + "version": "0.0.0", + "description": "Global logging utility", + "main": "index.js", + "scripts": { + "test": "lab -cv" + }, + "repository": { + "type": "git", + "url": "https://github.com/phated/glogg" + }, + "keywords": [ + "global", + "log", + "logging", + "logger", + "shared" + ], + "author": "Blaine Bublitz (http://iceddev.com/)", + "license": "MIT", + "bugs": { + "url": "https://github.com/phated/glogg/issues" + }, + "homepage": "https://github.com/phated/glogg", + "dependencies": { + "sparkles": "git://github.com/phated/sparkles" + }, + "devDependencies": { + "code": "^1.2.1", + "lab": "^5.1.1" + } +}