https://github.com/makerxstudio/color-console
https://github.com/makerxstudio/color-console
console library nodejs typescript
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/makerxstudio/color-console
- Owner: MakerXStudio
- License: mit
- Created: 2024-02-22T22:55:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-20T14:28:28.000Z (about 2 years ago)
- Last Synced: 2025-08-08T19:10:00.848Z (11 months ago)
- Topics: console, library, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 103 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# @makerx/color-console
Wraps [chalk](https://github.com/chalk/chalk) and [console](https://developer.mozilla.org/en-US/docs/Web/API/console) to provide a console interface which automatically formats [tagged template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates) with base text and interpolated arguments in different colours.
## Installation
```shell
npm i @makerx/color-console --save
```
## Example
```ts
import { colorConsole, createColorFormatter } from './index'
import chalk from 'chalk'
// Use the default colorConsole object
colorConsole.log`Example of log with args ${1}, ${2}, ${'three'}`
colorConsole.info`Example of info with args ${1}, ${2}, ${'three'}`
colorConsole.warn`Example of warn with args ${1}, ${2}, ${'three'}`
colorConsole.error`Example of error with args ${1}, ${2}, ${'three'}`
colorConsole.success`Example of success with args ${1}, ${2}, ${'three'}`
// Create your own custom formatter
const customLogger = createColorFormatter(chalk.magenta, chalk.greenBright, 'log', console)
customLogger`Example of custom with args ${1}, ${2}, ${'three'}`
```
will result in
