1 | # choo-log [![stability][0]][1]
|
2 | [![npm version][2]][3] [![build status][4]][5]
|
3 | [![downloads][8]][9] [![js-standard-style][10]][11]
|
4 |
|
5 | # This project has been deprecated. All functionality has been merged into [choo-devtools](https://github.com/choojs/choo-devtools/). Thanks for passing by!
|
6 |
|
7 | Development logger for [choo][12].
|
8 |
|
9 | ![screen capture](./screenshot.png)
|
10 |
|
11 | ## Usage
|
12 | ```js
|
13 | var log = require('choo-log')
|
14 | var choo = require('choo')
|
15 |
|
16 | var app = choo()
|
17 | app.use(log())
|
18 | app.mount('body')
|
19 | ```
|
20 |
|
21 | ## API
|
22 | ### `logger = log(opts)`
|
23 | Create a new logger instance. Opts can contain:
|
24 | - __timing:__ defaults to `true`. Disable calls to `window.performance` timing
|
25 | API. Timing calls will not run in browsers that don't support it out of the
|
26 | box.
|
27 | - __clearResourceTimings:__ defaults to `true`. Disable clearing the
|
28 | [window.performance resourcetimingbuffer][buf] when full. Set to `false` if
|
29 | the buffer is cleared somewhere else.
|
30 | - __colors:__ defaults to the default theme of [nanologger][15].
|
31 |
|
32 | ### `emitter.emit('log:<level>', msg)`
|
33 | Send a log event. `choo-log` will pass `log:<level>` events through to [nanologger](https://github.com/choojs/nanologger). For example:
|
34 |
|
35 | ```js
|
36 | emitter.emit('log:info', 'The rain in Spain stays mainly in the plain 🌧')
|
37 | ```
|
38 |
|
39 | These are just normal events, so you can listen to them in addition to them being logged:
|
40 |
|
41 | ```js
|
42 | emitter.on('log:debug', function (msg) {
|
43 | // do something with debug message
|
44 | })
|
45 | ```
|
46 |
|
47 | ### `localStorage.setItem('logLevel', <level>)`
|
48 |
|
49 | Set the [nanologger log level](https://github.com/choojs/nanologger#level--logloglevel), e.g.:
|
50 |
|
51 | ```js
|
52 | localStorage.setItem('logLevel','debug')
|
53 | ```
|
54 |
|
55 | ## Installation
|
56 | ```sh
|
57 | $ npm install choo-log
|
58 | ```
|
59 |
|
60 | ## License
|
61 | [MIT](https://tldrlegal.com/license/mit-license)
|
62 |
|
63 | [0]: https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square
|
64 | [1]: https://nodejs.org/api/documentation.html#documentation_stability_index
|
65 | [2]: https://img.shields.io/npm/v/choo-log.svg?style=flat-square
|
66 | [3]: https://npmjs.org/package/choo-log
|
67 | [4]: https://img.shields.io/travis/choojs/choo-log/master.svg?style=flat-square
|
68 | [5]: https://travis-ci.org/choojs/choo-log
|
69 | [6]: https://img.shields.io/codecov/c/github/choojs/choo-log/master.svg?style=flat-square
|
70 | [7]: https://codecov.io/github/choojs/choo-log
|
71 | [8]: http://img.shields.io/npm/dm/choo-log.svg?style=flat-square
|
72 | [9]: https://npmjs.org/package/choo-log
|
73 | [10]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
|
74 | [11]: https://github.com/feross/standard
|
75 | [12]: https://github.com/choojs/choo
|
76 | [13]: https://img.shields.io/badge/built%20for%20choo-v4-ffc3e4.svg?style=flat-square
|
77 | [14]: https://github.com/choojs/choo
|
78 | [15]: https://github.com/choojs/nanologger/blob/master/index.js#L17
|
79 | [buf]: https://developer.mozilla.org/en-US/docs/Web/API/Performance/onresourcetimingbufferfull
|