Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@nopecha/pprint

j-w-yun23MIT0.1.3TypeScript support: included

A pretty-print utility for Node.js

nopecha, pprint, pretty-print, prettyprint, pretty-printer, color print, colorful print, node pprint, node pretty-print, node color print, node colorful print, nodejs pprint, nodejs pretty-print, nodejs color print, nodejs colorful print, node.js pprint, node.js pretty-print, node.js color print, node.js colorful print, javascript pprint, javascript pretty-print, javascript color print, javascript colorful print, typescript pprint, typescript pretty-print, typescript color print, typescript colorful print

readme

@nopecha/pprint

npm version

This package provides pretty-print logging functions for Node.js.

Installation

npm install @nopecha/pprint

Usage

Add to the top of the entry file of the project.

import '@nopecha/pprint'

The above will expose the pretty-print logging functions to the global scope.

Replace console with global to color-code terminal outputs in Node.js.

Available are trace, debug, info, log, warn, and error.

global.trace()  // Red
global.debug('this is green')
global.info('this is cyan')
global.warn('this is yellow')
global.error('this is red')
global.log('this does not have a color yet')

Add color to log messages. Color codes are prefixed with ! in their own string.

global.log('!r', 'this is red')
global.log('!g', 'this is green')
global.log('!b', 'this is blue')

Add background colors with a second color code.

global.log('!rb', 'this is red on blue')

Add text styles with a third color code.

global.log('!uwd', 'underlined')    // underlined, white on dark
global.log('!bdw', 'bolded')        // bolded, dark on white
global.log('!igw', 'italicized')    // italicized, green on white

Multiple colors can be used in a single log statement.

Note that all color code strings including "!" are zero width, except "! " where a color-stop code can contain a space that is left untrimmed.

global.log('!r', 'this is red', '!', ' this is normal ', '!b', 'blue', '! ', 'normal')

© 2024 NopeCHA, LLC