pax_global_header00006660000000000000000000000064145776550270014534gustar00rootroot0000000000000052 comment=04a46b2477ce74dcb91d07c69740ebf8b433860c gulpjs-glogg-04a46b2/000077500000000000000000000000001457765502700144615ustar00rootroot00000000000000gulpjs-glogg-04a46b2/.editorconfig000066400000000000000000000003261457765502700171370ustar00rootroot00000000000000# http://editorconfig.org root = true [*] indent_style = space indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true end_of_line = lf [*.md] trim_trailing_whitespace = false gulpjs-glogg-04a46b2/.eslintignore000066400000000000000000000000121457765502700171550ustar00rootroot00000000000000coverage/ gulpjs-glogg-04a46b2/.eslintrc000066400000000000000000000000301457765502700162760ustar00rootroot00000000000000{ "extends": "gulp" } gulpjs-glogg-04a46b2/.gitattributes000066400000000000000000000000161457765502700173510ustar00rootroot00000000000000* text eol=lf gulpjs-glogg-04a46b2/.github/000077500000000000000000000000001457765502700160215ustar00rootroot00000000000000gulpjs-glogg-04a46b2/.github/workflows/000077500000000000000000000000001457765502700200565ustar00rootroot00000000000000gulpjs-glogg-04a46b2/.github/workflows/dev.yml000066400000000000000000000031051457765502700213560ustar00rootroot00000000000000name: dev on: pull_request: push: branches: - master - main env: CI: true jobs: prettier: name: Format code runs-on: ubuntu-latest if: ${{ github.event_name == 'push' }} steps: - name: Checkout uses: actions/checkout@v2 - name: Prettier uses: gulpjs/prettier_action@v3.0 with: commit_message: 'chore: Run prettier' prettier_options: '--write .' test: name: Tests for Node ${{ matrix.node }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: node: [10, 12, 14, 16] os: [ubuntu-latest, windows-latest, macos-latest] steps: - name: Clone repository uses: actions/checkout@v2 - name: Set Node.js version uses: actions/setup-node@v2 with: node-version: ${{ matrix.node }} - run: node --version - run: npm --version - name: Install npm dependencies run: npm install - name: Run lint run: npm run lint - name: Run tests run: npm test - name: Coveralls uses: coverallsapp/github-action@v1.1.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: ${{matrix.os}}-node-${{ matrix.node }} parallel: true coveralls: needs: test name: Finish up runs-on: ubuntu-latest steps: - name: Coveralls Finished uses: coverallsapp/github-action@v1.1.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} parallel-finished: true gulpjs-glogg-04a46b2/.github/workflows/release.yml000066400000000000000000000005511457765502700222220ustar00rootroot00000000000000name: release on: push: branches: - master - main jobs: release-please: runs-on: ubuntu-latest steps: - uses: GoogleCloudPlatform/release-please-action@v2 with: token: ${{ secrets.GITHUB_TOKEN }} release-type: node package-name: release-please-action bump-minor-pre-major: true gulpjs-glogg-04a46b2/.gitignore000066400000000000000000000017111457765502700164510ustar00rootroot00000000000000# Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # nyc test coverage .nyc_output # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) bower_components # node-waf configuration .lock-wscript # Compiled binary addons (https://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules/ jspm_packages/ # TypeScript v1 declaration files typings/ # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env # next.js build output .next # Garbage files .DS_Store # Test results test.xunit gulpjs-glogg-04a46b2/.npmrc000066400000000000000000000000231457765502700155740ustar00rootroot00000000000000package-lock=false gulpjs-glogg-04a46b2/.prettierignore000066400000000000000000000000441457765502700175220ustar00rootroot00000000000000coverage/ .nyc_output/ CHANGELOG.md gulpjs-glogg-04a46b2/CHANGELOG.md000066400000000000000000000020111457765502700162640ustar00rootroot00000000000000# Changelog ## [2.2.0](https://www.github.com/gulpjs/glogg/compare/v2.1.0...v2.2.0) (2024-03-23) ### Features * Re-emit messages from legacy namespace on new namespace ([#9](https://www.github.com/gulpjs/glogg/issues/9)) ([88350e4](https://www.github.com/gulpjs/glogg/commit/88350e44603b24b7b8295ee996a7afa7ba90ccb6)) ## [2.1.0](https://www.github.com/gulpjs/glogg/compare/v2.0.0...v2.1.0) (2024-03-10) ### Features * Emit all arguments when first argument is not a string ([#7](https://www.github.com/gulpjs/glogg/issues/7)) ([578a2aa](https://www.github.com/gulpjs/glogg/commit/578a2aaf1138e54f6e6e555bfbe555dd3f82fd35)) ## [2.0.0](https://www.github.com/gulpjs/glogg/compare/v1.0.2...v2.0.0) (2022-06-24) ### ⚠ BREAKING CHANGES * Normalize repository, dropping node <10.13 support (#5) ### Miscellaneous Chores * Normalize repository, dropping node <10.13 support ([#5](https://www.github.com/gulpjs/glogg/issues/5)) ([8bb6148](https://www.github.com/gulpjs/glogg/commit/8bb6148c061e0f11ea9330924e954c39af7f02b6)) gulpjs-glogg-04a46b2/LICENSE000066400000000000000000000022131457765502700154640ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2014, 2015, 2018, 2022 Blaine Bublitz and Eric Schoffstall 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. gulpjs-glogg-04a46b2/README.md000066400000000000000000000070251457765502700157440ustar00rootroot00000000000000

# glogg [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url] 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, ...args) 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. If the first argument is not a string, all arguments will be emitted directly. #### logger.info(msg, ...args) 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. If the first argument is not a string, all arguments will be emitted directly. #### logger.warn(msg, ...args) 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. If the first argument is not a string, all arguments will be emitted directly. #### logger.error(msg, ...args) 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. If the first argument is not a string, all arguments will be emitted directly. **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 [downloads-image]: https://img.shields.io/npm/dm/glogg.svg?style=flat-square [npm-url]: https://www.npmjs.com/package/glogg [npm-image]: https://img.shields.io/npm/v/glogg.svg?style=flat-square [ci-url]: https://github.com/gulpjs/glogg/actions?query=workflow:dev [ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/glogg/dev.yml?style=flat-square [coveralls-url]: https://coveralls.io/r/gulpjs/glogg [coveralls-image]: https://img.shields.io/coveralls/gulpjs/glogg/master.svg?style=flat-square gulpjs-glogg-04a46b2/index.js000066400000000000000000000021421457765502700161250ustar00rootroot00000000000000'use strict'; var format = require('util').format; var sparkles = require('sparkles'); var legacySparkles = require('sparkles/legacy'); var levels = ['debug', 'info', 'warn', 'error']; function getLogger(namespace) { var logger = sparkles(namespace); var deprecatedLogger = legacySparkles(namespace); levels.forEach(function (level) { logger[level] = makeLogLevel(logger, level); // Wire up listeners for every level on the deprecated namespace // If anything gets emitted on this namespace, we'll emit the // `deprecated` event and re-emit the event on the new logger deprecatedLogger.on(level, function () { logger.emit('deprecated'); var args = Array.prototype.slice.call(arguments); logger[level].apply(logger, args); }); }); return logger; } function makeLogLevel(self, level) { return function (msg) { if (typeof msg === 'string') { self.emit(level, format.apply(null, arguments)); } else { var args = Array.prototype.slice.call(arguments); self.emit.apply(self, [level].concat(args)); } }; } module.exports = getLogger; gulpjs-glogg-04a46b2/package.json000066400000000000000000000016741457765502700167570ustar00rootroot00000000000000{ "name": "glogg", "version": "2.2.0", "description": "Global logging utility", "author": "Gulp Team (http://gulpjs.com/)", "contributors": [ "Blaine Bublitz " ], "repository": "gulpjs/glogg", "license": "MIT", "engines": { "node": ">= 10.13.0" }, "main": "index.js", "files": [ "LICENSE", "index.js" ], "scripts": { "lint": "eslint .", "pretest": "npm run lint", "test": "nyc mocha --async-only" }, "dependencies": { "sparkles": "^2.1.0" }, "devDependencies": { "eslint": "^7.32.0", "eslint-config-gulp": "^5.0.1", "eslint-plugin-node": "^11.1.0", "expect": "^27.4.6", "mocha": "^8.4.0", "nyc": "^15.1.0" }, "nyc": { "reporter": [ "lcov", "text-summary" ] }, "prettier": { "singleQuote": true }, "keywords": [ "global", "log", "logger", "logging", "shared" ] } gulpjs-glogg-04a46b2/test/000077500000000000000000000000001457765502700154405ustar00rootroot00000000000000gulpjs-glogg-04a46b2/test/index.js000066400000000000000000000075371457765502700171210ustar00rootroot00000000000000'use strict'; var expect = require('expect'); var sparklesLegacy = require('sparkles/legacy'); 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).toEqual('test'); done(); }); logger.debug('test'); }); it('emits a info event when info method is called', function (done) { logger.on('info', function (msg) { expect(msg).toEqual('test'); done(); }); logger.info('test'); }); it('emits a warn event when warn method is called', function (done) { logger.on('warn', function (msg) { expect(msg).toEqual('test'); done(); }); logger.warn('test'); }); it('emits a error event when error method is called', function (done) { logger.on('error', function (msg) { expect(msg).toEqual('test'); done(); }); logger.error('test'); }); it('formats a string message with util.format syntax', function (done) { logger.on('debug', function (msg) { expect(msg).toEqual('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).toEqual(expected); done(); }); logger.debug(expected); }); it('emits all arguments to the log if non-string message', function (done) { var expected = { test: 'something' }; logger.on('debug', function (msg, extra) { expect(msg).toEqual(expected); expect(extra).toEqual(true); done(); }); logger.debug(expected, true); }); it('allows you to "destructure" the individual log-level functions', function (done) { var debug = logger.debug; logger.on('debug', function (msg) { expect(msg).toEqual('test'); done(); }); debug('test'); }); }); describe('events on legacy namespace', function () { var logger; var legacy; beforeEach(function (done) { var namespace = 'glogg-test'; logger = glogg(namespace); legacy = sparklesLegacy(namespace); done(); }); afterEach(function (done) { logger.remove(); legacy.remove(); done(); }); it('emits deprecated event and forwards debug to logger', function (done) { var deprecated = false; logger.on('deprecated', function () { deprecated = true; }); logger.on('debug', function (msg) { expect(deprecated).toEqual(true); expect(msg).toEqual('test'); done(); }); legacy.emit('debug', 'test'); }); it('emits deprecated event and forwards info to logger', function (done) { var deprecated = false; logger.on('deprecated', function () { deprecated = true; }); logger.on('info', function (msg) { expect(deprecated).toEqual(true); expect(msg).toEqual('test'); done(); }); legacy.emit('info', 'test'); }); it('emits deprecated event and forwards warn to logger', function (done) { var deprecated = false; logger.on('deprecated', function () { deprecated = true; }); logger.on('warn', function (msg) { expect(deprecated).toEqual(true); expect(msg).toEqual('test'); done(); }); legacy.emit('warn', 'test'); }); it('emits deprecated event and forwards error to logger', function (done) { var deprecated = false; logger.on('deprecated', function () { deprecated = true; }); logger.on('error', function (msg) { expect(deprecated).toEqual(true); expect(msg).toEqual('test'); done(); }); legacy.emit('error', 'test'); }); });