# chalk-log-plus

> A friendly terminal log output library based on chalk encapsulation

Latest version **0.0.1** (published 2022-07-17) · GNU-3 license · 0 weekly downloads

## Install

```sh
npm install chalk-log-plus
pnpm add chalk-log-plus
yarn add chalk-log-plus
bun add chalk-log-plus
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2022-07-17 |
| First published | 2022-07-17 |
| Weekly downloads | 0 |
| License | GNU-3 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 155.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | pcl-aacin |
| Maintainers | kingstarjun |
| Keywords | chalk, log, console |

## Links

- npm: https://www.npmjs.com/package/chalk-log-plus
- Repository: https://github.com/pcl-aacin/chalk-log
- Homepage: https://github.com/pcl-aacin/chalk-log#readme
- Issues: https://github.com/pcl-aacin/chalk-log/issues
- npm.io page: https://npm.io/package/chalk-log-plus

## Dependencies (1)

- [chalk](https://npm.io/package/chalk.md) ^4.1.2

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.0.1 (latest) — 2022-07-17

## README

<p align=center><img src="chalk-log-pro.png" width="320px" /></p>
<h1 align="center" name="chalk-log">ChalkLog</h1>
<p align="center">
  <em>A friendly terminal log output library based on chalk encapsulation</em>
</p>
<p align="center">
  
![Github Stars](https://img.shields.io/github/stars/pcl-aacin/chalk-log.svg)
![Chalk Version](https://img.shields.io/badge/chalk-%3C%204.1.2-lightgrey)
![license](https://img.shields.io/badge/LICENSE-GNU--3.0-brightgreen)
![Author](https://img.shields.io/badge/Author-pcl--aacin-green)
</p>

[中文](README.cn.md)

## Why to develop ChalkLog?

Because when I added the log output code of the express project, I found that if I directly used chat, there would be many repeated fragments in the code, and it was too complex. So I encapsulated this simple library on the basis of chalk.

## How to use?
### Install [chalk](https://www.npmjs.com/package/chalk) (Version less 5)
Chalk no longer supports the import of require() in nodejs after version 5, so you choose to use version 4 chalk. I will consider adapting chalks after version 5 in the future
```
npm install --save chalk@4
```

### Require ChalkLog
1) First download chalklog and put it into your nodejs project

2) Then call chalklog
``` node
const log = require("./chalk-log")
```

### Code supported
```log``` is a class, including the following functions

+ add
+ output

Initializing class

``` node
const clog = new log();
```

When initializing, you can consider adding prefixes. Chalklog has the following prefix presets (preset_class)

+ info
+ error
+ success
+ connect

For example

``` node
// Case insensitive
const clog = new log("info");
```

If these prefix presets can't satisfy you, you can also define the chalk style yourself

``` node
// The following codes are equivalent to "chalk.rgb(0,0,0).bold"

// 1
const chalk = require("chalk");
const clog = new log(chalk.rgb(0,0,0).bold,"text");

// 2
const clog = new log("rgb(0,0,0).bold","text");

// 3
const clog = new log([ "rgb(0,0,0)","bold" ],"text");
```

The add() function can append output

If you only need to output content without font style matching, you only need to pass in one parameter: output content

``` node
clog.add("infomations")
```

Otherwise, you need to pass in the following two parameters

The first parameter can be the preset color name. Chalklog provides the following color presets (preset_color)

+ host
+ error

As in initialization, if the preset color cannot meet your needs, you can also define it yourself in the same way as in initialization

The second parameter is the output content

Finally, the content is output only when output() is called

``` node
clog.output();
```

After using output() to output, you can still use add() to continue appending content and output again with output()

### Abbreviation supported
this code

``` node
const clog = new log("rgb(0,0,0).bold","text");
clog.add("infomations")
clog.output();
```

It can be abbreviated as

``` node
new log("rgb(0,0,0).bold","text").add("infomations").output();
```

It should be noted that if you use the shorthand method, you cannot use add() to continue adding content or output() to output after using output()

## Writing attention
1) You don't need to pay too much attention to the writing method when passing in the custom style of non chalk function (for example, when bold is required, "bold" and "bold()" are both OK)

<p align="center">I am still learning nodejs. If the program reports errors, please feed back in issues. Thank you for using!</p>

---
_Source: https://npm.io/package/chalk-log-plus · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
