- Notifications
You must be signed in to change notification settings - Fork1
node.js module for controlling cli verbosity
License
NotificationsYou must be signed in to change notification settings
thebespokepixel/verbosity
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An augmented drop-in console replacement that supports logging levels.
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 usingconsole.log()
etc.
Normally I pass in a granular verboseness level via arguments to control the verbosity level for the running process.
npm install --save verbosity
Simply override the built in console object:
import{createConsole}from'verbosity'constconsole=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.
import{createConsole}from'verbosity'constconsole=createConsole({outStream:process.stderr,verbosity:3})console.log('Picked brown jacket...')// Printedconsole.debug('Purple tie chosen...')// Not printedconsole.warn("That tie doesn't go with that jacket.")// Printed
Or go mad with making up any number of custom console writers.
import{createConsole}from'verbosity'constmyUberConsole=createConsole({outStream:myFancyWriteableStream,verbosity:5})myUberConsole.panic('Core Flux Capacitor Meltdown!')
Full documentation can be found athttps://thebespokepixel.github.io/verbosity/
About
node.js module for controlling cli verbosity
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published