diff options
Diffstat (limited to 'node_modules/webpack-log')
| -rw-r--r-- | node_modules/webpack-log/LICENSE | 21 | ||||
| -rw-r--r-- | node_modules/webpack-log/README.md | 132 | ||||
| -rw-r--r-- | node_modules/webpack-log/index.js | 76 | ||||
| l--------- | node_modules/webpack-log/node_modules/.bin/uuid | 1 | ||||
| -rw-r--r-- | node_modules/webpack-log/package.json | 48 |
5 files changed, 278 insertions, 0 deletions
diff --git a/node_modules/webpack-log/LICENSE b/node_modules/webpack-log/LICENSE new file mode 100644 index 00000000..1e1bdc96 --- /dev/null +++ b/node_modules/webpack-log/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 webpack-contrib + +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. diff --git a/node_modules/webpack-log/README.md b/node_modules/webpack-log/README.md new file mode 100644 index 00000000..e909b195 --- /dev/null +++ b/node_modules/webpack-log/README.md @@ -0,0 +1,132 @@ +<div align="center"> + <a href="https://github.com/webpack/webpack"> + <img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg"> + </a> +</div> + +[![npm][npm]][npm-url] +[![node][node]][node-url] +[![deps][deps]][deps-url] +[![tests][tests]][tests-url] +[![coverage][cover]][cover-url] +[![chat][chat]][chat-url] + +# webpack-log + +A common logging module for the Webpack ecosystem. `webpack-log` leverages +[`loglevelnext`][loglevelnext]. + +## Getting Started + +First thing's first, install the module: + +```console +npm install webpack-log --save +``` + +_Note: We do not recommend installing this module globally._ + +## Requirements + +`webpack-log` requires Node v6 or higher. + +## Usage + +```js +const weblog = require('webpack-log'); +const log = weblog({ name: 'wds' }) // webpack-dev-server + +log.info('Server Starting'); +``` + +The code above will produce: + + + +## Options + +The default export (`function`) will return a logger, given an `options` Object. +The following is a property reference for the Object. + +_Note: the logger returned is unique by default, due to the nature of the `webpack` +ecosystem. Please reference the [`unique`](#unique) option below for disabling +this feature and to force caching._ + +### level + +Type: `String` +Default: `'info'` + +Specifies the level the logger should use. A logger will not produce output for +any log level _beneath_ the specified level. Available levels and order are: + +```js +[ + 'trace', + 'debug', + 'info', + 'warn', + 'error', + 'silent' +] +``` + +_Note: The level names shown above correspond to the available logging methods, +with the notable exception of the `silent` level._ + +### name + +_Required_ +Type: `String` +Default: `'<unknown>'` + +Specifies the name of the log to create. This property is required, and used to +differentiate between loggers when `webpack-log` is used in multiple projects +executing in the same process space. + +### timestamp + +Type: `Boolean` +Default: `false` + +If `true`, instructs the logger to display a timestamp for log output, preceding +all other data. + +### unique + +Type: `Boolean` +Default: `true` + +If `false`, instructs the logger to used cached versions of a log with the same +name. Due to the nature of the `webpack` ecosystem and multiple plugin/loader +use in the same process space, loggers are created as unique instances by default. +By passing `false` for this property, the module is instructed to cache the +requested logger. + +## Contributing + +We welcome your contributions! Please have a read of [CONTRIBUTING.md](CONTRIBUTING.md) for more information on how to get involved. + +## License + +#### [MIT](./LICENSE) + +[npm]: https://img.shields.io/npm/v/webpack-log.svg +[npm-url]: https://npmjs.com/package/webpack-log + +[node]: https://img.shields.io/node/v/webpack-log.svg +[node-url]: https://nodejs.org + +[deps]: https://david-dm.org/webpack-contrib/webpack-log.svg +[deps-url]: https://david-dm.org/webpack-contrib/webpack-log + +[tests]: http://img.shields.io/travis/webpack-contrib/webpack-log.svg +[tests-url]: https://travis-ci.org/webpack-contrib/webpack-log + +[cover]: https://codecov.io/gh/webpack-contrib/webpack-log/branch/master/graph/badge.svg +[cover-url]: https://codecov.io/gh/webpack-contrib/webpack-log + +[chat]: https://badges.gitter.im/webpack/webpack.svg +[chat-url]: https://gitter.im/webpack/webpack + +[loglevelnext]: https://github.com/shellscape/loglevelnext diff --git a/node_modules/webpack-log/index.js b/node_modules/webpack-log/index.js new file mode 100644 index 00000000..79a2cabd --- /dev/null +++ b/node_modules/webpack-log/index.js @@ -0,0 +1,76 @@ +'use strict'; + +const chalk = require('chalk'); +const loglevel = require('loglevelnext'); //eslint-disable-line +const logSymbols = require('log-symbols'); +const uuid = require('uuid/v4'); + +const symbols = { + trace: chalk.grey('₸'), + debug: chalk.cyan('➤'), + info: logSymbols.info, + warn: logSymbols.warning, + error: logSymbols.error +}; + +const defaults = { + name: '<unknown>', + level: 'info', + unique: true +}; + +const prefix = { + level: opts => symbols[opts.level], + template: `{{level}} ${chalk.gray('「{{name}}」')}: ` +}; + +module.exports = function webpackLog(options) { + const opts = Object.assign({}, defaults, options); + const { id } = options; + + opts.prefix = Object.assign({}, prefix, options.prefix); + delete opts.id; + + Object.defineProperty(opts, 'id', { + get() { + if (!id) { + return this.name + (opts.unique ? `-${uuid()}` : ''); + } + + return id; + } + }); + + if (opts.timestamp) { + opts.prefix.template = `[{{time}}] ${opts.prefix.template}`; + } + + const log = loglevel.getLogger(opts); + + if (!Object.prototype.hasOwnProperty.call(log, 'id')) { + Object.defineProperty(log, 'id', { + get() { + return opts.id; + } + }); + } + + return log; +}; + +// NOTE: this is exported so that consumers of webpack-log can use the same +// version of chalk to decorate log messages without incurring additional +// dependency overhead. This is an atypical practice, but chalk version +// segmentation is a common issue. +module.exports.chalk = chalk; + +/** + * @NOTE: This is an undocumented function solely for the purpose of tests. + * Do not use this method in production code. Using in production code + * may result in strange behavior. + */ +module.exports.delLogger = function delLogger(name) { + delete loglevel.loggers[name]; +}; + +module.exports.factories = loglevel.factories; diff --git a/node_modules/webpack-log/node_modules/.bin/uuid b/node_modules/webpack-log/node_modules/.bin/uuid new file mode 120000 index 00000000..740f800c --- /dev/null +++ b/node_modules/webpack-log/node_modules/.bin/uuid @@ -0,0 +1 @@ +../../../uuid/bin/uuid
\ No newline at end of file diff --git a/node_modules/webpack-log/package.json b/node_modules/webpack-log/package.json new file mode 100644 index 00000000..899d7a9e --- /dev/null +++ b/node_modules/webpack-log/package.json @@ -0,0 +1,48 @@ +{ + "name": "webpack-log", + "version": "1.2.0", + "description": "A common logging module for the Webpack ecosystem", + "license": "MIT", + "repository": "webpack-contrib/webpack-log", + "author": "Andrew Powell <andrew@shellscape.org>", + "homepage": "http://github.com/webpack-contrib/webpack-log", + "maintainers": [ + { + "name": "Andrew Powell", + "email": "andrew@shellscape.org", + "url": "shellscape.org" + } + ], + "main": "index.js", + "engines": { + "node": ">=6" + }, + "scripts": { + "beautify": "npm run lint -- --fix", + "ci": "npm run cover -- --report lcovonly && npm run test", + "cover": "istanbul cover node_modules/mocha/bin/_mocha", + "lint": "eslint index.js test", + "mocha": "mocha --full-trace --check-leaks", + "test": "npm run lint && npm run mocha" + }, + "files": [ + "index.js" + ], + "dependencies": { + "chalk": "^2.1.0", + "log-symbols": "^2.1.0", + "loglevelnext": "^1.0.1", + "uuid": "^3.1.0" + }, + "devDependencies": { + "assert": "^1.4.1", + "codecov.io": "^0.1.6", + "eslint": "^4.5.0", + "eslint-config-webpack": "^1.2.5", + "eslint-plugin-import": "^2.7.0", + "istanbul": "^0.4.5", + "mocha": "^4.0.0", + "sinon": "^4.0.1", + "strip-ansi": "^4.0.0" + } +} |
