Projekt

Obecné

Profil

Stáhnout (3.31 KB) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
<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
16
A common logging module for the Webpack ecosystem. `webpack-log` leverages
17
[`loglevelnext`][loglevelnext].
18
19
## Getting Started
20
21
First thing's first, install the module:
22
23
```console
24
npm 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
36
const weblog = require('webpack-log');
37
const log = weblog({ name: 'wds' }) // webpack-dev-server
38
39
log.info('Server Starting');
40
```
41
42
The code above will produce:
43
44
![output](output.png)
45
46
## Options
47
48
The default export (`function`) will return a logger, given an `options` Object.
49
The 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`
52
ecosystem. Please reference the [`unique`](#unique) option below for disabling
53
this feature and to force caching._
54
55
### level
56
57
Type: `String`  
58
Default: `'info'`
59
60
Specifies the level the logger should use. A logger will not produce output for
61
any 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,
75
with the notable exception of the `silent` level._
76
77
### name
78
79
_Required_  
80
Type: `String`  
81
Default: `'<unknown>'`
82
83
Specifies the name of the log to create. This property is required, and used to
84
differentiate between loggers when `webpack-log` is used in multiple projects
85
executing in the same process space.
86
87
### timestamp
88
89
Type: `Boolean`  
90
Default: `false`
91
92
If `true`, instructs the logger to display a timestamp for log output, preceding
93
all other data.
94
95
### unique
96
97
Type: `Boolean`  
98
Default: `true`
99
100
If `false`, instructs the logger to used cached versions of a log with the same
101
name. Due to the nature of the `webpack` ecosystem and multiple plugin/loader
102
use in the same process space, loggers are created as unique instances by default.
103
By passing `false` for this property, the module is instructed to cache the
104
requested logger.
105
106
## Contributing
107
108
We 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