You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
3.3 KiB

4 years ago
  1. <div align="center">
  2. <a href="https://github.com/webpack/webpack">
  3. <img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
  4. </a>
  5. </div>
  6. [![npm][npm]][npm-url]
  7. [![node][node]][node-url]
  8. [![deps][deps]][deps-url]
  9. [![tests][tests]][tests-url]
  10. [![coverage][cover]][cover-url]
  11. [![chat][chat]][chat-url]
  12. # webpack-log
  13. A common logging module for the Webpack ecosystem. `webpack-log` leverages
  14. [`loglevelnext`][loglevelnext].
  15. ## Getting Started
  16. First thing's first, install the module:
  17. ```console
  18. npm install webpack-log --save
  19. ```
  20. _Note: We do not recommend installing this module globally._
  21. ## Requirements
  22. `webpack-log` requires Node v6 or higher.
  23. ## Usage
  24. ```js
  25. const weblog = require('webpack-log');
  26. const log = weblog({ name: 'wds' }) // webpack-dev-server
  27. log.info('Server Starting');
  28. ```
  29. The code above will produce:
  30. ![output](output.png)
  31. ## Options
  32. The default export (`function`) will return a logger, given an `options` Object.
  33. The following is a property reference for the Object.
  34. _Note: the logger returned is unique by default, due to the nature of the `webpack`
  35. ecosystem. Please reference the [`unique`](#unique) option below for disabling
  36. this feature and to force caching._
  37. ### level
  38. Type: `String`
  39. Default: `'info'`
  40. Specifies the level the logger should use. A logger will not produce output for
  41. any log level _beneath_ the specified level. Available levels and order are:
  42. ```js
  43. [
  44. 'trace',
  45. 'debug',
  46. 'info',
  47. 'warn',
  48. 'error',
  49. 'silent'
  50. ]
  51. ```
  52. _Note: The level names shown above correspond to the available logging methods,
  53. with the notable exception of the `silent` level._
  54. ### name
  55. _Required_
  56. Type: `String`
  57. Default: `'<unknown>'`
  58. Specifies the name of the log to create. This property is required, and used to
  59. differentiate between loggers when `webpack-log` is used in multiple projects
  60. executing in the same process space.
  61. ### timestamp
  62. Type: `Boolean`
  63. Default: `false`
  64. If `true`, instructs the logger to display a timestamp for log output, preceding
  65. all other data.
  66. ### unique
  67. Type: `Boolean`
  68. Default: `true`
  69. If `false`, instructs the logger to used cached versions of a log with the same
  70. name. Due to the nature of the `webpack` ecosystem and multiple plugin/loader
  71. use in the same process space, loggers are created as unique instances by default.
  72. By passing `false` for this property, the module is instructed to cache the
  73. requested logger.
  74. ## Contributing
  75. We welcome your contributions! Please have a read of [CONTRIBUTING.md](CONTRIBUTING.md) for more information on how to get involved.
  76. ## License
  77. #### [MIT](./LICENSE)
  78. [npm]: https://img.shields.io/npm/v/webpack-log.svg
  79. [npm-url]: https://npmjs.com/package/webpack-log
  80. [node]: https://img.shields.io/node/v/webpack-log.svg
  81. [node-url]: https://nodejs.org
  82. [deps]: https://david-dm.org/webpack-contrib/webpack-log.svg
  83. [deps-url]: https://david-dm.org/webpack-contrib/webpack-log
  84. [tests]: http://img.shields.io/travis/webpack-contrib/webpack-log.svg
  85. [tests-url]: https://travis-ci.org/webpack-contrib/webpack-log
  86. [cover]: https://codecov.io/gh/webpack-contrib/webpack-log/branch/master/graph/badge.svg
  87. [cover-url]: https://codecov.io/gh/webpack-contrib/webpack-log
  88. [chat]: https://badges.gitter.im/webpack/webpack.svg
  89. [chat-url]: https://gitter.im/webpack/webpack
  90. [loglevelnext]: https://github.com/shellscape/loglevelnext