.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / loglevel-colored-level-prefix / README.md
1 # loglevel-colored-level-prefix
2
3 loglevel plugin that adds colored level prefix (node only)
4
5 [![Build Status][build-badge]][build]
6 [![Code Coverage][coverage-badge]][coverage]
7 [![Dependencies][dependencyci-badge]][dependencyci]
8 [![version][version-badge]][package]
9 [![downloads][downloads-badge]][npm-stat]
10 [![MIT License][license-badge]][LICENSE]
11
12 [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)
13 [![PRs Welcome][prs-badge]][prs]
14 [![Donate][donate-badge]][donate]
15 [![Code of Conduct][coc-badge]][coc]
16 [![Roadmap][roadmap-badge]][roadmap]
17 [![Examples][examples-badge]][examples]
18
19 [![Watch on GitHub][github-watch-badge]][github-watch]
20 [![Star on GitHub][github-star-badge]][github-star]
21 [![Tweet][twitter-badge]][twitter]
22
23 ## The problem
24
25 [`loglevel`][loglevel] is great, and I find that I often want the log output to
26 be formatted the same way every time. Also I don't really like some of the
27 implementation of `loglevel` (specifically the fact that it uses some browser
28 APIs for some things.
29
30 ## This solution
31
32 This exposes a function to get a logger (singleton) with colored prefixes for
33 the level. Note that this only works in Node because it uses [`chalk`][chalk].
34
35 ## Installation
36
37 This module is distributed via [npm][npm] which is bundled with [node][node] and should
38 be installed as one of your project's `dependencies`:
39
40 ```
41 npm install --save loglevel-colored-level-prefix
42 ```
43
44 ## Usage
45
46 ```javascript
47 const getLogger = require('loglevel-colored-level-prefix')
48 const options = {prefix: 'your-prefix', level: 'trace'}
49 const logger = getLogger(options)
50 logger.trace('WOW! What the stack trace!?')
51 // Trace: your-prefix [TRACE]: WOW! What the stack trace!?
52 //     at Logger.trace (<full-path>/node_modules/loglevel-colored-level-prefix/dist/index.js:54:24)
53 //     at ... etc
54 logger.debug('sup debug?')
55 // your-prefix [DEBUG]: sup debug?
56 logger.info('Hey info')
57 // your-prefix [INFO]: Hey info
58 logger.warn('Hi warn')
59 // your-prefix [WARN]: Hi warn
60 logger.error('Hello error')
61 // your-prefix [ERROR]: Hello error
62 ```
63
64 Let's look at what that actually looks like...
65
66 [![][screenshot]][screenshot]
67
68 ### options
69
70 #### prefix
71
72 **?String** - Whatever you want your prefix to be. Normally this is the tool
73 that you're logging for. The `getLogger` function will return the same instance
74 of the logger based on the given prefix.
75
76 #### level
77
78 **?String** - What you want the initial level to be set to. This defaults to:
79 `process.env.LOG_LEVEL || 'warn'`. Possible options are (in order of verbosity):
80 `trace`, `debug`, `info`, `warn`, `error`.
81
82 ### returns
83
84 An instance of a `loglevel` logger. Learn more about that API from the
85 [`loglevel` docs][loglevel].
86
87 ## Inspiration
88
89 I wrote this because I wanted to use the plugin I created for
90 [`prettier-eslint`][prettier-eslint] in
91 [`prettier-eslint-cli`][prettier-eslint-cli]. And I'll probably use it in other
92 projects/tools as well.
93
94 ## Other Solutions
95
96 I'm unaware of other plugins for `loglevel` that do what this one does. But
97 there are _many_ logging solutions out there...
98
99 ## Contributors
100
101 Thanks goes to these people ([emoji key][emojis]):
102
103 <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
104 | [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](https://kentcdodds.com)<br />[💻](https://github.com/kentcdodds/loglevel-colored-level-prefix/commits?author=kentcdodds) [📖](https://github.com/kentcdodds/loglevel-colored-level-prefix/commits?author=kentcdodds) 🚇 [⚠️](https://github.com/kentcdodds/loglevel-colored-level-prefix/commits?author=kentcdodds) |
105 | :---: |
106 <!-- ALL-CONTRIBUTORS-LIST:END -->
107
108 This project follows the [all-contributors][all-contributors] specification. Contributions of any kind welcome!
109
110 ## LICENSE
111
112 MIT
113
114 [npm]: https://www.npmjs.com/
115 [node]: https://nodejs.org
116 [build-badge]: https://img.shields.io/travis/kentcdodds/loglevel-colored-level-prefix.svg?style=flat-square
117 [build]: https://travis-ci.org/kentcdodds/loglevel-colored-level-prefix
118 [coverage-badge]: https://img.shields.io/codecov/c/github/kentcdodds/loglevel-colored-level-prefix.svg?style=flat-square
119 [coverage]: https://codecov.io/github/kentcdodds/loglevel-colored-level-prefix
120 [dependencyci-badge]: https://dependencyci.com/github/kentcdodds/loglevel-colored-level-prefix/badge?style=flat-square
121 [dependencyci]: https://dependencyci.com/github/kentcdodds/loglevel-colored-level-prefix
122 [version-badge]: https://img.shields.io/npm/v/loglevel-colored-level-prefix.svg?style=flat-square
123 [package]: https://www.npmjs.com/package/loglevel-colored-level-prefix
124 [downloads-badge]: https://img.shields.io/npm/dm/loglevel-colored-level-prefix.svg?style=flat-square
125 [npm-stat]: http://npm-stat.com/charts.html?package=loglevel-colored-level-prefix&from=2016-04-01
126 [license-badge]: https://img.shields.io/npm/l/loglevel-colored-level-prefix.svg?style=flat-square
127 [license]: https://github.com/kentcdodds/loglevel-colored-level-prefix/blob/master/other/LICENSE
128 [prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
129 [prs]: http://makeapullrequest.com
130 [donate-badge]: https://img.shields.io/badge/$-support-green.svg?style=flat-square
131 [donate]: http://kcd.im/donate
132 [coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
133 [coc]: https://github.com/kentcdodds/loglevel-colored-level-prefix/blob/master/other/CODE_OF_CONDUCT.md
134 [roadmap-badge]: https://img.shields.io/badge/%F0%9F%93%94-roadmap-CD9523.svg?style=flat-square
135 [roadmap]: https://github.com/kentcdodds/loglevel-colored-level-prefix/blob/master/other/ROADMAP.md
136 [examples-badge]: https://img.shields.io/badge/%F0%9F%92%A1-examples-8C8E93.svg?style=flat-square
137 [examples]: https://github.com/kentcdodds/loglevel-colored-level-prefix/blob/master/other/EXAMPLES.md
138 [github-watch-badge]: https://img.shields.io/github/watchers/kentcdodds/loglevel-colored-level-prefix.svg?style=social
139 [github-watch]: https://github.com/kentcdodds/loglevel-colored-level-prefix/watchers
140 [github-star-badge]: https://img.shields.io/github/stars/kentcdodds/loglevel-colored-level-prefix.svg?style=social
141 [github-star]: https://github.com/kentcdodds/loglevel-colored-level-prefix/stargazers
142 [twitter]: https://twitter.com/intent/tweet?text=Check%20out%20loglevel-colored-level-prefix!%20https://github.com/kentcdodds/loglevel-colored-level-prefix%20%F0%9F%91%8D
143 [twitter-badge]: https://img.shields.io/twitter/url/https/github.com/kentcdodds/loglevel-colored-level-prefix.svg?style=social
144 [emojis]: https://github.com/kentcdodds/all-contributors#emoji-key
145 [all-contributors]: https://github.com/kentcdodds/all-contributors
146 [loglevel]: https://www.npmjs.com/package/loglevel
147 [prettier-eslint]: https://github.com/kentcdodds/prettier-eslint
148 [prettier-eslint-cli]: https://github.com/kentcdodds/prettier-eslint-cli
149 [chalk]: https://www.npmjs.com/package/chalk
150 [screenshot]: https://raw.githubusercontent.com/kentcdodds/loglevel-colored-level-prefix/master/other/screenshot.png