New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

beautify-console-log

Package Overview
Dependencies
Maintainers
0
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beautify-console-log - npm Package Compare versions

Comparing version 1.3.15 to 1.3.16

2

package.json
{
"name": "beautify-console-log",
"version": "1.3.15",
"version": "1.3.16",
"description": "This is a further beautification and encapsulation of the 'console' object. You can use it like using \"console. log\", \"console. info\", \"console. warn\", \"console. error\", and it can display the code line information where the log is printed.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -56,3 +56,3 @@ # beautify-console-log

```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -69,3 +69,3 @@

or
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -76,3 +76,3 @@ const log = new BeautifyConsole();

or
```
```javascript

@@ -87,3 +87,3 @@ const log = new BeautifyConsole();

Or directly use the `dist/index. js` file
```
```javascript
<script src="./dist/index.js">

@@ -97,6 +97,5 @@ <script>

</script>
```
```
```javascript
const log = BeautifyConsole.default.getInstance()

@@ -119,6 +118,35 @@

```
If you want to turn off redundant logs in the generation environment, you can configure it as follows:
```javascript
import BeautifyConsole from "beautify-console-log";
import { LogType } from 'beautify-console-log/lib/beautify-console/model';
const log = BeautifyConsole.getInstance();
2. initial configuration
/**
* Vite uses import.meta.env MODE retrieves the environment
*/
log.config({
title: 'custom title',
type: process.env.NODE_ENV === 'product' ? ['error'] : ['log', 'info', 'warn', 'error']
})
log.info(1234, '4', [3, 5]); // Will not display printing
```
Or
```javascript
import BeautifyConsole from "beautify-console-log";
import { LogType } from 'beautify-console-log/lib/beautify-console/model';
const log = BeautifyConsole.getInstance();
/**
* Vite uses import.meta.env MODE retrieves the environment
*/
if (process.env.NODE_ENV === 'product') {
log.close().open(LogType.error);
}
log.info(1234, '4', [3, 5]); // Will not display printing
```
2. initial configuration
```javascript
const log = BeautifyConsole.getInstance();
import { LogType } from 'beautify-console-log/lib/beautify-console/model';

@@ -137,3 +165,3 @@ log.config({

```
```javascript

@@ -154,3 +182,3 @@ const log = BeautifyConsole.getInstance();

```
```javascript

@@ -168,3 +196,3 @@ const log = BeautifyConsole.getInstance();

supports chain calling.
```
```javascript
// ...

@@ -196,3 +224,3 @@ const log = BeautifyConsole.getInstance();

```
```javascript
// ...

@@ -228,3 +256,3 @@ const log = BeautifyConsole.getInstance();

|└──type |LogType[] \| ('info' 、 'log' 、 'warn' 、 'error')[] |The type of log displayed, set to only display the corresponding log type(`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`、`"info"`、`"log"`、`"warn"`、`"error"`)|
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -246,3 +274,3 @@ import { LogType } from 'beautify-console-log/lib/beautify-console/model';

> The usage method is consistent with the normal console.log
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -258,3 +286,3 @@ const log = BeautifyConsole.getInstance();

> The usage method is consistent with the normal console.info
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -270,3 +298,3 @@ const log = BeautifyConsole.getInstance();

> The usage method is consistent with the normal console.warn
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -280,3 +308,3 @@ const log = BeautifyConsole.getInstance();

> The usage method is consistent with the normal console.error
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -293,3 +321,3 @@ const log = BeautifyConsole.getInstance();

|LogType \| "info" \| "log" \| "warn" \| "error" |`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`、`"info"`、`"log"`、`"warn"`、`"error"`, Or not transmitted|
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -310,3 +338,3 @@ import { LogType } from 'beautify-console-log/lib/beautify-console/model';

|LogType \| "info" \| "log" \| "warn" \| "error" |`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`、`"info"`、`"log"`、`"warn"`、`"error"`, Or not transmitted|
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -332,3 +360,3 @@ import { LogType } from 'beautify-console-log/lib/beautify-console/model';

| |└──bgColor (ColorType \| 'black' \| 'red' \| 'green' \| 'yellow' \| 'blue' \| 'purple' \| 'cyan' \| 'white') |`ColorType.black`,`ColorType.red`,`ColorType.green`,`ColorType.yellow`,`ColorType.blue`,`ColorType.purple`,`ColorType.cyan`,`ColorType.white`|
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -364,3 +392,3 @@ import { LogType, ColorType } from 'beautify-console-log/lib/beautify-console/model';

After setting custom log headers or closing some logs, you can reset them through `log.reset()`.
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -367,0 +395,0 @@ import { LogType } from 'beautify-console-log/lib/beautify-console/model';

@@ -49,3 +49,3 @@ # beautify-console-log

- 为了方便使用(也为了兼容老版本),我把参数定义为多种类型,比如使用`config`配置时,可以传入`type`值为:`LogType`类型,也可以传入字符串`"info"`、`"log"`、`"warn"`、`"error"`。
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -59,3 +59,3 @@ const log = BeautifyConsole.getInstance();

```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -67,3 +67,3 @@ const log = new BeautifyConsole();

```
```javascript
const log = new BeautifyConsole();

@@ -75,3 +75,3 @@ // 使用方式与正常的console.info()一致

也可以直接使用 `dist/index.js` 文件
```
```javascript
<script src="./dist/index.js">

@@ -86,3 +86,3 @@ <script>

```
```
```javascript
const log = BeautifyConsole.default.getInstance()

@@ -136,6 +136,35 @@

```
如果想在生成环境关闭多余日志,可以这么配置:
```javascript
import BeautifyConsole from "beautify-console-log";
import { LogType } from 'beautify-console-log/lib/beautify-console/model';
const log = BeautifyConsole.getInstance();
2. 初始化配置
/**
* vite 使用 import.meta.env.MODE 获取环境
*/
log.config({
title: 'custom title',
type: process.env.NODE_ENV === 'product' ? ['error'] : ['log', 'info', 'warn', 'error']
})
log.info(1234, '4', [3, 5]); // 不会显示打印
```
或者
```javascript
import BeautifyConsole from "beautify-console-log";
import { LogType } from 'beautify-console-log/lib/beautify-console/model';
const log = BeautifyConsole.getInstance();
/**
* vite 使用 import.meta.env.MODE 获取环境
*/
if (process.env.NODE_ENV === 'product') {
log.close().open(LogType.error);
}
log.info(1234, '4', [3, 5]); // 不会显示打印
```
2. 初始化配置
```javascript
const log = BeautifyConsole.getInstance();
import { LogType } from 'beautify-console-log/lib/beautify-console/model';

@@ -154,3 +183,3 @@ log.config({

3. 支持的console类型
```
```javascript
const log = BeautifyConsole.getInstance();

@@ -163,3 +192,3 @@ log.info(1234, '4', [3, 5]);

4. 加入自定义console日志头
```
```javascript
const log = BeautifyConsole.getInstance();

@@ -177,3 +206,3 @@ log.setPadStartText({

5. 关闭日志,传入参数就关闭对应的console日志类型,不传就关闭所有的类型,支持链式调用
```
```javascript
// ...省略

@@ -200,3 +229,3 @@ const log = BeautifyConsole.getInstance();

6. 打开日志,传入参数就打开对应的console日志类型,不传就打开所有的类型,支持链式调用
```
```javascript
const log = BeautifyConsole.getInstance();

@@ -230,3 +259,3 @@ log.open(LogType.info);

|└──type |LogType[] \| ('info' 、 'log' 、 'warn' 、 'error')[] |显示的日志类型,设置后只显示对应的日志类型(`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`、`"info"`、`"log"`、`"warn"`、`"error"`)|
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -248,3 +277,3 @@ import { LogType } from 'beautify-console-log/lib/beautify-console/model';

> 使用方式与正常的console.log()一致
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -260,3 +289,3 @@ const log = BeautifyConsole.getInstance();

> 使用方式与正常的console.info()一致
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -272,3 +301,3 @@ const log = BeautifyConsole.getInstance();

> 使用方式与正常的console.warn()一致
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -282,3 +311,3 @@ const log = BeautifyConsole.getInstance();

> 使用方式与正常的console.error()一致
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -295,3 +324,3 @@ const log = BeautifyConsole.getInstance();

|LogType \| "info" \| "log" \| "warn" \| "error" |`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`,或者不传|
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -312,3 +341,3 @@ import { LogType } from 'beautify-console-log/lib/beautify-console/model';

|LogType \| "info" \| "log" \| "warn" \| "error" |`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`、`"info"`、`"log"`、`"warn"`、`"error"`,或者不传|
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -334,3 +363,3 @@ import { LogType } from 'beautify-console-log/lib/beautify-console/model';

| |└──bgColor? (ColorType \| 'black' \| 'red' \| 'green' \| 'yellow' \| 'blue' \| 'purple' \| 'cyan' \| 'white') |`ColorType.black`,`ColorType.red`,`ColorType.green`,`ColorType.yellow`,`ColorType.blue`,`ColorType.purple`,`ColorType.cyan`,`ColorType.white`|
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -366,3 +395,3 @@ import { LogType, ColorType } from 'beautify-console-log/lib/beautify-console/model';

当设置自定义日志头或关闭部分日志等操作后,可以通过`log.reset()`重置。
```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -437,3 +466,3 @@ import { LogType } from 'beautify-console-log/lib/beautify-console/model';

```
```javascript
import BeautifyConsole from "beautify-console-log";

@@ -440,0 +469,0 @@ import { formatConsoleStr } from 'beautify-console-log/lib/utils';

@@ -44,6 +44,6 @@ import { formatConsoleStr } from "../utils";

expect(log.log({ name: "chengzan" })).toBe(undefined);
expect(log.close().warn(1234)).toBe(undefined);
expect(log.open().log(1234)).toBe(undefined);
expect(log.error(1234)).toBe(undefined);
expect(log.warn(1234)).toBe(undefined);
expect(log.close().warn('warn')).toBe(undefined);
expect(log.open().log('log')).toBe(undefined);
expect(log.error('error')).toBe(undefined);
expect(log.warn('warn')).toBe(undefined);
expect(

@@ -50,0 +50,0 @@ log

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc