Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

node.js module for controlling cli verbosity

License

NotificationsYou must be signed in to change notification settings

thebespokepixel/verbosity

Repository files navigation

An augmented drop-in console replacement that supports logging levels.

Publishing Status

npmLibraries.io
TravisRollup

Development Status

TravisLibraries.io
SnykCode-ClimateCode-Climate Coverage

Documentation/Help

Inch.ioTwitter

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 usingconsole.log() etc.

Normally I pass in a granular verboseness level via arguments to control the verbosity level for the running process.

Installation

npm install --save verbosity

Examples

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!')

Documentation

Full documentation can be found athttps://thebespokepixel.github.io/verbosity/


[8]ページ先頭

©2009-2025 Movatter.jp