UNPKG

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