https://github.com/thebespokepixel/verbosity
node.js module for controlling cli verbosity
https://github.com/thebespokepixel/verbosity
cli console logging node-module npm terminal verbosity verbosity-level
Last synced: about 1 year ago
JSON representation
node.js module for controlling cli verbosity
- Host: GitHub
- URL: https://github.com/thebespokepixel/verbosity
- Owner: thebespokepixel
- License: mit
- Created: 2015-09-28T21:22:08.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-03-14T17:53:42.000Z (over 3 years ago)
- Last Synced: 2025-04-30T21:07:05.775Z (about 1 year ago)
- Topics: cli, console, logging, node-module, npm, terminal, verbosity, verbosity-level
- Language: JavaScript
- Homepage: http://thebespokepixel.github.io/verbosity/
- Size: 22.1 MB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 14
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# verbosity
> An augmented drop-in console replacement that supports logging levels.
##### Publishing Status
[](https://www.npmjs.com/package/verbosity "npm") [](https://libraries.io/github/thebespokepixel/verbosity "Libraries.io")
[](https://travis-ci.com/thebespokepixel/verbosity "Travis") [](https://github.com/rollup/rollup/wiki/pkg.module "Rollup")
##### Development Status
[](https://travis-ci.com/thebespokepixel/verbosity "Travis") [](https://libraries.io/github/thebespokepixel/verbosity "Libraries.io")
[](https://snyk.io/test/github/thebespokepixel/verbosity "Snyk") [](https://codeclimate.com/github/thebespokepixel/verbosity/maintainability "Code-Climate") [](https://codeclimate.com/github/thebespokepixel/verbosity/test_coverage "Code-Climate Coverage")
##### Documentation/Help
[](https://inch-ci.org/github/thebespokepixel/verbosity "Inch.io") [](https://twitter.com/thebespokepixel "Twitter")
## Usage
#### About
I wanted to be able to have chattier daemons running in development, and more succinct logging in production but wanted to keep the simplicity of using `console.log()` etc.
Normally I pass in a granular verboseness level via arguments to control the verbosity level for the running process.
#### Installation
```shell
npm install --save verbosity
```
#### Examples
Simply override the built in console object:
```javascript
import {createConsole} from 'verbosity'
const console = createConsole({
outStream: process.stdout,
errorStream: process.stderr,
verbosity: 5
})
console.log('Works like normal...')
console.debug('...but now controllable.')
console.verbosity(3) // Use numbered levels 5 (debug) to 1 (error)
console.debug('...this isn’t printed now.')
console.canWrite(5) && console.dir({print: 'this won’t.'})
console.verbosity('debug') // Use named levels [debug, info, log, warning, error]
console.canWrite(5) && console.dir({print: 'this will now.'})
```
This will direct all console output to stderr, but silence 'info' and 'debug' messages.
```javascript
import {createConsole} from 'verbosity'
const console = createConsole({
outStream: process.stderr,
verbosity: 3
})
console.log('Picked brown jacket...') // Printed
console.debug('Purple tie chosen...') // Not printed
console.warn("That tie doesn't go with that jacket.") // Printed
```
Or go mad with making up any number of custom console writers.
```javascript
import {createConsole} from 'verbosity'
const myUberConsole = createConsole({
outStream: myFancyWriteableStream,
verbosity: 5
})
myUberConsole.panic('Core Flux Capacitor Meltdown!')
```
## Documentation
Full documentation can be found at [https://thebespokepixel.github.io/verbosity/][1]
[1]: https://thebespokepixel.github.io/verbosity/