Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jessety/simple-log-colors

Extremely lightweight zero-dependency library for coloring Node terminal output
https://github.com/jessety/simple-log-colors

Last synced: 5 days ago
JSON representation

Extremely lightweight zero-dependency library for coloring Node terminal output

Awesome Lists containing this project

README

        

# simple-log-colors

Extremely lightweight zero-dependency library for coloring Node terminal output

[![build](https://github.com/jessety/simple-log-colors/workflows/ci/badge.svg)](https://github.com/jessety/simple-log-colors/actions)
[![npm](https://img.shields.io/npm/v/simple-log-colors.svg)](https://www.npmjs.com/package/simple-log-colors)
[![license](https://img.shields.io/github/license/jessety/simple-log-colors.svg)](https://github.com/jessety/simple-log-colors/blob/main/LICENSE)

## Install

```bash
npm install simple-log-colors
```

## Usage

```javascript
// Modules
import colors from 'simple-log-colors';

// CommonJS
const colors = require('simple-log-colors');
```

Template strings

```javascript
console.log(`Hello, ${colors.blue('world')}!`);
console.log(`Everything looks ${colors.cyan('better')} with a little ${colors.magenta('color')}!`);
```

Concatenation

```javascript
console.log(colors.redBackground('WARNING') + ' things are getting pretty ' + colors.yellow('colorful') + ' around here.');
```

Functions

```javascript
const { red, green, blue } = require('simple-log-colors');

console.log(`${red('Error')} the ${green('POST')} request to the ${blue('/test')} route was not signed properly.`);
```

## Colors

The following colors are supported:

- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`

All of these colors are also supported as background colors. For background colors, add the suffix `Background` onto a supported color.

```javascript
console.error(colors.redBackground('ERROR'));
```

## License

MIT © Jesse Youngblood