├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitattributes ├── .github └── workflows │ ├── dev.yml │ └── release.yml ├── .gitignore ├── .npmrc ├── .prettierignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── index.d.ts ├── index.js ├── package.json └── test └── index.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "gulp" 3 | } 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | -------------------------------------------------------------------------------- /.github/workflows/dev.yml: -------------------------------------------------------------------------------- 1 | name: dev 2 | on: 3 | pull_request: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | env: 9 | CI: true 10 | 11 | jobs: 12 | prettier: 13 | name: Format code 14 | runs-on: ubuntu-latest 15 | if: ${{ github.event_name == 'push' }} 16 | 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v2 20 | 21 | - name: Prettier 22 | uses: gulpjs/prettier_action@v3.0 23 | with: 24 | commit_message: 'chore: Run prettier' 25 | prettier_options: '--write .' 26 | 27 | test: 28 | name: Tests for Node ${{ matrix.node }} on ${{ matrix.os }} 29 | runs-on: ${{ matrix.os }} 30 | 31 | strategy: 32 | fail-fast: false 33 | matrix: 34 | node: [10, 12, 14, 16] 35 | os: [ubuntu-latest, windows-latest, macos-latest] 36 | 37 | steps: 38 | - name: Clone repository 39 | uses: actions/checkout@v2 40 | 41 | - name: Set Node.js version 42 | uses: actions/setup-node@v2 43 | with: 44 | node-version: ${{ matrix.node }} 45 | 46 | - run: node --version 47 | - run: npm --version 48 | 49 | - name: Install npm dependencies 50 | run: npm install 51 | 52 | - name: Run lint 53 | run: npm run lint 54 | 55 | - name: Run tests 56 | run: npm test 57 | 58 | - name: Coveralls 59 | uses: coverallsapp/github-action@v1.1.2 60 | with: 61 | github-token: ${{ secrets.GITHUB_TOKEN }} 62 | flag-name: ${{matrix.os}}-node-${{ matrix.node }} 63 | parallel: true 64 | 65 | coveralls: 66 | needs: test 67 | name: Finish up 68 | 69 | runs-on: ubuntu-latest 70 | steps: 71 | - name: Coveralls Finished 72 | uses: coverallsapp/github-action@v1.1.2 73 | with: 74 | github-token: ${{ secrets.GITHUB_TOKEN }} 75 | parallel-finished: true 76 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | on: 3 | push: 4 | branches: 5 | - master 6 | - main 7 | 8 | jobs: 9 | release-please: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: GoogleCloudPlatform/release-please-action@v2 13 | with: 14 | token: ${{ secrets.GITHUB_TOKEN }} 15 | release-type: node 16 | package-name: release-please-action 17 | bump-minor-pre-major: true 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | 63 | # Garbage files 64 | .DS_Store 65 | 66 | # Test results 67 | test.xunit 68 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | .nyc_output/ 3 | CHANGELOG.md 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # gulplog changelog 2 | 3 | ## [2.2.0](https://www.github.com/gulpjs/gulplog/compare/v2.1.0...v2.2.0) (2024-03-23) 4 | 5 | 6 | ### Features 7 | 8 | * Upgrade glogg to handle events from older versions ([4999733](https://www.github.com/gulpjs/gulplog/commit/4999733621311f409bf29673361315ee023cb261)) 9 | 10 | ## [2.1.0](https://www.github.com/gulpjs/gulplog/compare/v2.0.1...v2.1.0) (2024-03-10) 11 | 12 | 13 | ### Features 14 | 15 | * Log all arguments when first argument is not a string ([#19](https://www.github.com/gulpjs/gulplog/issues/19)) ([323a27a](https://www.github.com/gulpjs/gulplog/commit/323a27aa8d451d4389adbfea8dbd2317c1b44451)) 16 | 17 | ### [2.0.1](https://www.github.com/gulpjs/gulplog/compare/v2.0.0...v2.0.1) (2022-09-28) 18 | 19 | 20 | ### Bug Fixes 21 | 22 | * Include TypeScript definition file in package ([f4aee89](https://www.github.com/gulpjs/gulplog/commit/f4aee89952538290511ff4c7585e9ed35170ccdf)) 23 | 24 | ## [2.0.0](https://www.github.com/gulpjs/gulplog/compare/v1.0.0...v2.0.0) (2022-06-24) 25 | 26 | 27 | ### ⚠ BREAKING CHANGES 28 | 29 | * Normalize repository, dropping node <10.13 support (#13) 30 | 31 | ### Features 32 | 33 | * Add TypeScript type definition file ([#12](https://www.github.com/gulpjs/gulplog/issues/12)) ([b5ce699](https://www.github.com/gulpjs/gulplog/commit/b5ce699f8646d9c5f231e3a4a130d61891545e2a)) 34 | 35 | 36 | ### Miscellaneous Chores 37 | 38 | * Normalize repository, dropping node <10.13 support ([#13](https://www.github.com/gulpjs/gulplog/issues/13)) ([da9b3ad](https://www.github.com/gulpjs/gulplog/commit/da9b3ad292e47c1d7f379f142394f29bb3f15be4)) 39 | 40 | ## 1.0.0 41 | 42 | - Initial release 43 | - No implementation changed since initial commit 44 | 45 | ## 0.0.0 46 | 47 | - Experimentation 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015, 2017, 2022 Blaine Bublitz and Eric Schoffstall 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | 5 |

6 | 7 | # gulplog 8 | 9 | [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url] 10 | 11 | Logger for gulp and gulp plugins 12 | 13 | ## Usage 14 | 15 | ```js 16 | var logger = require('gulplog'); 17 | 18 | // logs strings 19 | logger.debug('The MOST verbose!'); 20 | logger.info('Some important info'); 21 | logger.warn('All the warnings to you'); 22 | logger.error('OH NO! SOMETHING HAPPENED!'); 23 | 24 | // supports util.format! 25 | logger.info('%s style!', 'printf'); 26 | 27 | // log anything 28 | logger.debug({ my: 'obj' }); 29 | logger.info([1, 2, 3]); 30 | ``` 31 | 32 | ## API 33 | 34 | Logging (and level of logging) is controlled by [`gulp-cli`][gulp-cli-url] 35 | 36 | #### logger.debug(msg, ...args) 37 | 38 | Highest log level. Typically used for debugging purposes. 39 | 40 | If the first argument is a string, all arguments are passed to node's 41 | [`util.format()`][util-format-url] before being emitted. 42 | 43 | If the first argument is not a string, all arguments will be emitted directly. 44 | 45 | #### logger.info(msg, ...args) 46 | 47 | Standard log level. Typically used for user information. 48 | 49 | If the first argument is a string, all arguments are passed to node's 50 | [`util.format()`][util-format-url] before being emitted. 51 | 52 | If the first argument is not a string, all arguments will be emitted directly. 53 | 54 | #### logger.warn(msg, ...args) 55 | 56 | Warning log level. Typically used for warnings. 57 | 58 | If the first argument is a string, all arguments are passed to node's 59 | [`util.format()`][util-format-url] before being emitted. 60 | 61 | If the first argument is not a string, all arguments will be emitted directly. 62 | 63 | #### logger.error(msg, ...args) 64 | 65 | Error log level. Typically used when things went horribly wrong. 66 | 67 | If the first argument is a string, all arguments are passed to node's 68 | [`util.format()`][util-format-url] before being emitted. 69 | 70 | If the first argument is not a string, all arguments will be emitted directly. 71 | 72 | ## License 73 | 74 | MIT 75 | 76 | 77 | [downloads-image]: https://img.shields.io/npm/dm/gulplog.svg?style=flat-square 78 | [npm-url]: https://npmjs.org/package/gulplog 79 | [npm-image]: https://img.shields.io/npm/v/gulplog.svg?style=flat-square 80 | 81 | [ci-url]: https://github.com/gulpjs/gulplog/actions?query=workflow:dev 82 | [ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/gulplog/dev.yml?branch=master&style=flat-square 83 | 84 | [coveralls-url]: https://coveralls.io/r/gulpjs/gulplog 85 | [coveralls-image]: https://img.shields.io/coveralls/gulpjs/gulplog/master.svg?style=flat-square 86 | 87 | 88 | 89 | [gulp-cli-url]: https://github.com/gulpjs/gulp-cli 90 | [util-format-url]: https://nodejs.org/docs/latest/api/util.html#util_util_format_format 91 | 92 | -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Highest log level. Typically used for debugging purposes. 3 | * 4 | * If the first argument is a string, all arguments are passed to node's util.format() before being emitted. 5 | * 6 | * If the first argument is not a string, all arguments will be emitted directly. 7 | * 8 | * @param msg Message to log 9 | * @param args Additional arguments 10 | */ 11 | export function debug(msg: any, ...args: any[]): void; 12 | /** 13 | * Standard log level. Typically used for user information. 14 | * 15 | * If the first argument is a string, all arguments are passed to node's util.format() before being emitted. 16 | * 17 | * If the first argument is not a string, all arguments will be emitted directly. 18 | * 19 | * @param msg Message to log 20 | * @param args Additional arguments 21 | */ 22 | export function info(msg: any, ...args: any[]): void; 23 | /** 24 | * Warning log level. Typically used for warnings. 25 | * 26 | * If the first argument is a string, all arguments are passed to node's util.format() before being emitted. 27 | * 28 | * If the first argument is not a string, all arguments will be emitted directly. 29 | * 30 | * @param msg Message to log 31 | * @param args Additional arguments 32 | */ 33 | export function warn(msg: any, ...args: any[]): void; 34 | /** 35 | * Error log level. Typically used when things went horribly wrong. 36 | * 37 | * If the first argument is a string, all arguments are passed to node's util.format() before being emitted. 38 | * 39 | * If the first argument is not a string, all arguments will be emitted directly. 40 | * 41 | * @param msg Message to log 42 | * @param args Additional arguments 43 | */ 44 | export function error(msg: any, ...args: any[]): void; 45 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var getLogger = require('glogg'); 4 | 5 | var logger = getLogger('gulplog'); 6 | 7 | module.exports = logger; 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gulplog", 3 | "version": "2.2.0", 4 | "description": "Logger for gulp and gulp plugins", 5 | "author": "Gulp Team (http://gulpjs.com/)", 6 | "contributors": [ 7 | "Blaine Bublitz " 8 | ], 9 | "repository": "gulpjs/gulplog", 10 | "license": "MIT", 11 | "engines": { 12 | "node": ">= 10.13.0" 13 | }, 14 | "main": "index.js", 15 | "types": "index.d.ts", 16 | "files": [ 17 | "LICENSE", 18 | "index.js", 19 | "index.d.ts" 20 | ], 21 | "scripts": { 22 | "lint": "eslint .", 23 | "pretest": "npm run lint", 24 | "test": "nyc mocha --async-only" 25 | }, 26 | "dependencies": { 27 | "glogg": "^2.2.0" 28 | }, 29 | "devDependencies": { 30 | "eslint": "^7.32.0", 31 | "eslint-config-gulp": "^5.0.1", 32 | "eslint-plugin-node": "^11.1.0", 33 | "expect": "^27.3.1", 34 | "mocha": "^8.4.0", 35 | "nyc": "^15.1.0" 36 | }, 37 | "nyc": { 38 | "reporter": [ 39 | "lcov", 40 | "text-summary" 41 | ] 42 | }, 43 | "prettier": { 44 | "singleQuote": true 45 | }, 46 | "keywords": [ 47 | "gulp", 48 | "log", 49 | "logging" 50 | ] 51 | } 52 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var expect = require('expect'); 4 | 5 | var logger = require('../'); 6 | 7 | describe('gulplog', function () { 8 | after(function (done) { 9 | logger.remove(); 10 | done(); 11 | }); 12 | 13 | afterEach(function (done) { 14 | logger.removeAllListeners(); 15 | done(); 16 | }); 17 | 18 | it('should emit the appropriate event when debug/info/warn/error methods are called', function (done) { 19 | var called = { debug: 0, info: 0, warn: 0, error: 0 }; 20 | function allDone() { 21 | if (called.debug && called.info && called.warn && called.error) { 22 | expect(called.debug).toEqual(1); 23 | expect(called.info).toEqual(1); 24 | expect(called.warn).toEqual(1); 25 | expect(called.error).toEqual(1); 26 | done(); 27 | } 28 | } 29 | 30 | logger.on('debug', function (msg) { 31 | expect(msg).toEqual('The MOST verbose!'); 32 | called.debug++; 33 | allDone(); 34 | }); 35 | 36 | logger.on('info', function (msg) { 37 | expect(msg).toEqual('Some important info'); 38 | called.info++; 39 | allDone(); 40 | }); 41 | 42 | logger.on('warn', function (msg) { 43 | expect(msg).toEqual('All the warnings to you'); 44 | called.warn++; 45 | allDone(); 46 | }); 47 | 48 | logger.on('error', function (msg) { 49 | expect(msg).toEqual('OH NO! SOMETHING HAPPENED!'); 50 | called.error++; 51 | allDone(); 52 | }); 53 | 54 | logger.debug('The MOST verbose!'); 55 | logger.info('Some important info'); 56 | logger.warn('All the warnings to you'); 57 | logger.error('OH NO! SOMETHING HAPPENED!'); 58 | }); 59 | 60 | it('should support util.format syntax', function (done) { 61 | logger.on('debug', function (msg) { 62 | expect(msg).toEqual('printf style!'); 63 | done(); 64 | }); 65 | 66 | logger.debug('%s style!', 'printf'); 67 | }); 68 | 69 | it('should log an object as it is', function (done) { 70 | logger.on('debug', function (msg) { 71 | expect(msg).toEqual({ my: 'obj' }); 72 | done(); 73 | }); 74 | 75 | logger.debug({ my: 'obj' }); 76 | }); 77 | 78 | it('should log an array as it is', function (done) { 79 | logger.on('info', function (msg) { 80 | expect(msg).toEqual([1, 2, 3]); 81 | done(); 82 | }); 83 | 84 | logger.info([1, 2, 3]); 85 | }); 86 | 87 | it('logs all arguments if first argument is not a string', function (done) { 88 | logger.on('info', function (arg1, arg2) { 89 | expect(arg1).toEqual([1, 2, 3]); 90 | expect(arg2).toEqual([4, 5, 6]); 91 | done(); 92 | }); 93 | 94 | logger.info([1, 2, 3], [4, 5, 6]); 95 | }); 96 | }); 97 | --------------------------------------------------------------------------------