pax_global_header00006660000000000000000000000064125744257230014525gustar00rootroot0000000000000052 comment=2683314c5bb5473e0d492418974b111f366168db glogg-1.0.0/000077500000000000000000000000001257442572300126225ustar00rootroot00000000000000glogg-1.0.0/.editorconfig000066400000000000000000000003051257442572300152750ustar00rootroot00000000000000# http://editorconfig.org root = true [*] indent_style = space indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.md] trim_trailing_whitespace = false glogg-1.0.0/.eslintrc000066400000000000000000000000471257442572300144470ustar00rootroot00000000000000{ "extends": "@phated/iceddev/es5" } glogg-1.0.0/.gitignore000066400000000000000000000011461257442572300146140ustar00rootroot00000000000000# Logs logs *.log # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directory # Commenting this out is preferred by some people, see # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules # Users Environment Variables .lock-wscript # Garbage files .DS_Store glogg-1.0.0/.travis.yml000066400000000000000000000002131257442572300147270ustar00rootroot00000000000000sudo: false language: node_js node_js: - '4' - '0.12' - '0.10' before_install: - 'npm install -g npm' # need those scoped packages glogg-1.0.0/LICENSE000066400000000000000000000020721257442572300136300ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014 Blaine Bublitz Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. glogg-1.0.0/README.md000066400000000000000000000046701257442572300141100ustar00rootroot00000000000000# glogg [![Travis Build Status](https://img.shields.io/travis/undertakerjs/glogg/master.svg?label=travis&style=flat-square)](https://travis-ci.org/undertakerjs/glogg) Global logging utility ## Usage ```js var getLogger = require('glogg'); var logger = getLogger('my-namespace'); // logs strings logger.debug('The MOST verbose!'); logger.info('Some important info'); logger.warn('All the warnings to you'); logger.error('OH NO! SOMETHING HAPPENED!'); // supports util.format! logger.info('%s style!', 'printf'); // log anything logger.debug({ my: 'obj' }); logger.info([1, 2, 3]); // somewhere else logger.on('info', function(msg){ // do something with msg }); // must be handled to avoid crashing process logger.on('error', function(msg){ // now it won't crash }); ``` ## API __Note: This module makes no assumptions about the log levels and they will always be emitted. If you are looking to filter some out, your listeners will need to have extra logic.__ ### getLogger([namespace]) Create a new logger at the given namespace (or the default if no namespace is provided). Returns an augmented [`sparkles`](https://github.com/phated/sparkles) EventEmitter object with 4 methods: `debug()`, `info()`, `warn()` and `error()`. When called, these methods emit an event with the same name. If the first argument is a string, the arguments are passed through node's `util.format()` before being emitted. Other parts of a node program can get the logger by namespace and listen for the events to be emitted. #### logger.debug(msg) Emits a `debug` event with the given `msg`. If the first argument is a string, all arguments are passed to node's `util.format()` before being emitted. #### logger.info(msg) Emits a `info` event with the given `msg`. If the first argument is a string, all arguments are passed to node's `util.format()` before being emitted. #### logger.warn(msg) Emits a `warn` event with the given `msg`. If the first argument is a string, all arguments are passed to node's `util.format()` before being emitted. #### logger.error(msg) Emits a `error` event with the given `msg`. If the first argument is a string, all arguments are passed to node's `util.format()` before being emitted. __Note: You must handle this event in some way or the node process will crash when an `error` event is emitted.__ #### logger.on(event, fn) Standard API from node's `EventEmitter`. Use this to listen for events from the logger methods. ## License MIT glogg-1.0.0/index.js000066400000000000000000000010101257442572300142570ustar00rootroot00000000000000'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; glogg-1.0.0/package.json000066400000000000000000000014061257442572300151110ustar00rootroot00000000000000{ "name": "glogg", "version": "1.0.0", "description": "Global logging utility", "author": "Blaine Bublitz (http://iceddev.com/)", "contributors": [], "repository": "undertakerjs/glogg", "license": "MIT", "engines": { "node": ">= 0.10" }, "main": "index.js", "files": [ "LICENSE", "index.js" ], "scripts": { "test": "lab -cvL --globals store@sparkles" }, "dependencies": { "sparkles": "^1.0.0" }, "devDependencies": { "@phated/eslint-config-iceddev": "^0.2.1", "code": "^1.5.0", "eslint": "^1.3.1", "eslint-plugin-mocha": "^0.5.1", "eslint-plugin-react": "^3.3.2", "lab": "^5.16.0" }, "keywords": [ "global", "log", "logger", "logging", "shared" ] } glogg-1.0.0/test/000077500000000000000000000000001257442572300136015ustar00rootroot00000000000000glogg-1.0.0/test/index.js000066400000000000000000000032611257442572300152500ustar00rootroot00000000000000'use strict'; var lab = exports.lab = require('lab').script(); var expect = require('code').expect; var describe = lab.describe; var it = lab.it; var beforeEach = lab.beforeEach; var afterEach = lab.afterEach; var glogg = require('../'); describe('glogg', function(){ var logger; beforeEach(function(done){ logger = glogg('glogg-test'); done(); }); afterEach(function(done){ logger.remove(); done(); }); it('emits a debug event when debug method is called', function(done){ logger.on('debug', function(msg){ expect(msg).to.equal('test'); done(); }); logger.debug('test'); }); it('emits a info event when info method is called', function(done){ logger.on('info', function(msg){ expect(msg).to.equal('test'); done(); }); logger.info('test'); }); it('emits a warn event when warn method is called', function(done){ logger.on('warn', function(msg){ expect(msg).to.equal('test'); done(); }); logger.warn('test'); }); it('emits a error event when error method is called', function(done){ logger.on('error', function(msg){ expect(msg).to.equal('test'); done(); }); logger.error('test'); }); it('formats a string message with util.format syntax', function(done){ logger.on('debug', function(msg){ expect(msg).to.equal('test something'); done(); }); logger.debug('test %s', 'something'); }); it('does not format a non-string message', function(done){ var expected = { test: 'something' }; logger.on('debug', function(msg){ expect(msg).to.deep.equal(expected); done(); }); logger.debug(expected); }); });