Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/j-w-yun/node-pprint
A pretty-print utility for Node.js
https://github.com/j-w-yun/node-pprint
Last synced: about 7 hours ago
JSON representation
A pretty-print utility for Node.js
- Host: GitHub
- URL: https://github.com/j-w-yun/node-pprint
- Owner: j-w-yun
- License: mit
- Created: 2024-05-13T21:50:39.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-05-13T23:32:07.000Z (6 months ago)
- Last Synced: 2024-11-15T20:06:29.665Z (4 days ago)
- Language: TypeScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @nopecha/pprint
[![npm version](https://badge.fury.io/js/@nopecha%2Fpprint.svg)](https://badge.fury.io/js/@nopecha%2Fpprint)
This package provides pretty-print logging functions for Node.js.
## Installation
```bash
npm install @nopecha/pprint
```## Usage
Add to the top of the entry file of the project.
```typescript
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`.
```typescript
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.
```typescript
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.
```typescript
global.log('!rb', 'this is red on blue')
```Add text styles with a third color code.
```typescript
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.
```typescript
global.log('!r', 'this is red', '!', ' this is normal ', '!b', 'blue', '! ', 'normal')
```## Copyright
© 2024 [NopeCHA, LLC](https://nopecha.com/)