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.0 to 1.3.1

44

lib/beautify-console/index.d.ts

@@ -1,2 +0,2 @@

import { LogType, PadStartText } from "./model";
import { BaseConfig, LogType, PadStartText } from "./model";
/**

@@ -30,3 +30,3 @@ * BeautifyConsole 是console日志工具

* config(config: {
* type?: LogType[];
* type?: LogType[] | ('info' | 'log' | 'warn' | 'error')[];
* title?: string;

@@ -48,19 +48,32 @@ * }): void;

private logPadStartText;
/**
* Print info type information
*/
info: (...args: any[]) => void;
/**
* Print error type information
*/
error: (...args: any[]) => void;
/**
* Print warn type information
*/
warn: (...args: any[]) => void;
/**
* Print log type information
*/
log: (...args: any[]) => void;
private static instance;
static getInstance(): BeautifyConsole;
/**
* Singleton mode
*/ static getInstance(): BeautifyConsole;
/**
* 初始化配置项
* @param config 是否打印日志 type { BaseConfig: {type?: LogType[] | ('info' | 'log' | 'warn' | 'error')[]; title?: string} }
* 如果配置了type,就只显示配置的日志类型
*/
config(config: {
type?: LogType[];
title?: string;
}): void;
config(config: BaseConfig): void;
/**
* 设置显示/隐藏console日志
* @param showLog 是否打印日志 type { boolean }
* @param type 需要设置的日志类型日志 type { LogType }
* @param type 需要设置的日志类型日志 type { LogType | 'info' | 'log' | 'warn' | 'error' }
*/

@@ -71,4 +84,2 @@ private setShowLog;

*
* @param type 需要设置的日志类型日志 type { LogType }
*
* @returns BeautifyConsole

@@ -80,19 +91,20 @@ */

*
* @param type 需要设置的日志类型日志 type { LogType }
* @param type 需要设置的日志类型日志 type { LogType | 'info' | 'log' | 'warn' | 'error' }
*
* @returns BeautifyConsole
*/
open(type?: LogType): BeautifyConsole;
open(type?: LogType | "info" | "log" | "warn" | "error"): BeautifyConsole;
/**
* 关闭console日志
*
* @param type 需要设置的日志类型日志 type { LogType }
* @param type 需要设置的日志类型日志 type { LogType | 'info' | 'log' | 'warn' | 'error' }
*
* @returns BeautifyConsole
*/
close(type?: LogType): BeautifyConsole;
close(type?: LogType | "info" | "log" | "warn" | "error"): BeautifyConsole;
/**
* 重置开始的填充文本console日志,默认如info类型的开始填充: `cbeautify-console-log info: -> `
* @param type type { consoleType }
* @param text type { any }
* @param title type { string }
* @param logType type { logType | 'info' | 'log' | 'warn' | 'error' }
* @param style type { PadStartStyle }
* @returns BeautifyConsole

@@ -99,0 +111,0 @@ */

@@ -71,3 +71,3 @@ "use strict";

* config(config: {
* type?: LogType[];
* type?: LogType[] | ('info' | 'log' | 'warn' | 'error')[];
* title?: string;

@@ -90,8 +90,22 @@ * }): void;

this.logPadStartText = padText[model_1.LogType.log]();
/**
* Print info type information
*/
this.info = console.info.bind(this, ...this.infoPadStartText);
/**
* Print error type information
*/
this.error = console.error.bind(this, ...this.errorPadStartText);
/**
* Print warn type information
*/
this.warn = console.warn.bind(this, ...this.warnPadStartText);
/**
* Print log type information
*/
this.log = console.log.bind(this, ...this.logPadStartText);
}
static getInstance() {
/**
* Singleton mode
*/ static getInstance() {
if (!this.instance) {

@@ -104,2 +118,4 @@ this.instance = new BeautifyConsole();

* 初始化配置项
* @param config 是否打印日志 type { BaseConfig: {type?: LogType[] | ('info' | 'log' | 'warn' | 'error')[]; title?: string} }
* 如果配置了type,就只显示配置的日志类型
*/

@@ -122,3 +138,3 @@ config(config) {

* @param showLog 是否打印日志 type { boolean }
* @param type 需要设置的日志类型日志 type { LogType }
* @param type 需要设置的日志类型日志 type { LogType | 'info' | 'log' | 'warn' | 'error' }
*/

@@ -175,4 +191,2 @@ setShowLog(showLog, type) {

*
* @param type 需要设置的日志类型日志 type { LogType }
*
* @returns BeautifyConsole

@@ -187,3 +201,3 @@ */

*
* @param type 需要设置的日志类型日志 type { LogType }
* @param type 需要设置的日志类型日志 type { LogType | 'info' | 'log' | 'warn' | 'error' }
*

@@ -199,3 +213,3 @@ * @returns BeautifyConsole

*
* @param type 需要设置的日志类型日志 type { LogType }
* @param type 需要设置的日志类型日志 type { LogType | 'info' | 'log' | 'warn' | 'error' }
*

@@ -210,4 +224,5 @@ * @returns BeautifyConsole

* 重置开始的填充文本console日志,默认如info类型的开始填充: `cbeautify-console-log info: -> `
* @param type type { consoleType }
* @param text type { any }
* @param title type { string }
* @param logType type { logType | 'info' | 'log' | 'warn' | 'error' }
* @param style type { PadStartStyle }
* @returns BeautifyConsole

@@ -214,0 +229,0 @@ */

/**
* 基础配置
* ```text
* {
* type?: LogType[] | ('info' | 'log' | 'warn' | 'error')[];
* title?: string;
* }
* ```
*/
export interface BaseConfig {
type?: LogType[] | ('info' | 'log' | 'warn' | 'error')[];
title?: string;
}
/**
* 背景编号:

@@ -72,3 +85,3 @@ *

* title: string;
* logType: LogType;
* logType: LogType | 'info' | 'log' | 'warn' | 'error';
* style?: PadStartStyle;

@@ -80,3 +93,3 @@ * }

title: string;
logType: LogType;
logType: LogType | 'info' | 'log' | 'warn' | 'error';
style?: PadStartStyle;

@@ -83,0 +96,0 @@ }

{
"name": "beautify-console-log",
"version": "1.3.0",
"version": "1.3.1",
"description": "This is a further beautification and encapsulation of the 'console' object, including console. log, console. info, console. warn, and console. error. It can display the number of rows where the log is printed.",

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

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

|title |String |Custom log header |
|type |LogType[] |The type of log displayed, set to only display the corresponding log type(`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`)|
|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"`)|
```

@@ -62,3 +62,3 @@ import BeautifyConsole from "beautify-console-log";

title: 'custom title',
type: [LogType.info, LogType.error]
type: [LogType.info, LogType.error, 'log']
})

@@ -112,3 +112,3 @@ // The usage method is consistent with the normal console.info

|-----------------------------|-----------------------------|
|LogType? |`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`, Or not transmitted|
|LogType 、 "info" 、 "log" 、 "warn" 、 "error" |`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`、`"info"`、`"log"`、`"warn"`、`"error"`, Or not transmitted|
```

@@ -129,3 +129,3 @@ import BeautifyConsole from "beautify-console-log";

|-----------------------------|-----------------------------|
|LogType? |`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`, Or not transmitted|
|LogType 、 "info" 、 "log" 、 "warn" 、 "error" |`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`、`"info"`、`"log"`、`"warn"`、`"error"`, Or not transmitted|
```

@@ -148,3 +148,3 @@ import BeautifyConsole from "beautify-console-log";

|title |String |Custom log header |
|logType |LogType |`LogType.info`,`LogType.log`,`LogType.warn`,`LogType.error`|
|logType | LogType 、 "info" 、 "log" 、 "warn" 、 "error" |`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`、`"info"`、`"log"`、`"warn"`、`"error"`|
|style |Object ||

@@ -151,0 +151,0 @@ | |├──color (ColorType) |`ColorType.black`,`ColorType.red`,`ColorType.green`,`ColorType.yellow`,`ColorType.blue`,`ColorType.purple`,`ColorType.cyan`,`ColorType.white`|

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

|title |String |自定义日志头 |
|type |LogType[] |显示的日志类型,设置后只显示对应的日志类型(`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`)|
|type |LogType[] 、 ('info' 、 'log' 、 'warn' 、 'error')[] |显示的日志类型,设置后只显示对应的日志类型(`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`、`"info"`、`"log"`、`"warn"`、`"error"`)|
```

@@ -55,3 +55,3 @@ import BeautifyConsole from "beautify-console-log";

title: 'custom title',
type: [LogType.info, LogType.error]
type: [LogType.info, LogType.error, 'log']
})

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

|-----------------------------|-----------------------------|
|LogType? |`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`,或者不传|
|LogType 、 "info" 、 "log" 、 "warn" 、 "error" |`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`,或者不传|
```

@@ -122,3 +122,3 @@ import BeautifyConsole from "beautify-console-log";

|-----------------------------|-----------------------------|
|LogType? |`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`,或者不传|
|LogType 、 "info" 、 "log" 、 "warn" 、 "error" |`LogType.info`、`LogType.log`、`LogType.warn`、`LogType.error`、`"info"`、`"log"`、`"warn"`、`"error"`,或者不传|
```

@@ -141,3 +141,3 @@ import BeautifyConsole from "beautify-console-log";

|title |String |自定义日志头 |
|logType |String |`LogType.info`,`LogType.log`,`LogType.warn`,`LogType.error`|
|logType | LogType 、 "info" 、 "log" 、 "warn" 、 "error" |`LogType.info`,`LogType.log`,`LogType.warn`,`LogType.error`、`"info"`、`"log"`、`"warn"`、`"error"`|
|style |Object ||

@@ -144,0 +144,0 @@ | |├──color |`ColorType.black`,`ColorType.red`,`ColorType.green`,`ColorType.yellow`,`ColorType.blue`,`ColorType.purple`,`ColorType.cyan`,`ColorType.white`,`cyan`,`white`|

@@ -16,3 +16,3 @@ import { LogType } from "../beautify-console/model";

title: "hello world ->",
logType: LogType.info,
logType: 'info',
})

@@ -19,0 +19,0 @@ .log(1234),

@@ -1,2 +0,8 @@

import { BaseColorType, ColorType, LogType, PadStartText } from "./model";
import {
BaseColorType,
BaseConfig,
ColorType,
LogType,
PadStartText,
} from "./model";

@@ -13,3 +19,3 @@ /**

text: string,
type: LogType,
type: LogType
): string => {

@@ -20,9 +26,5 @@ const { color = ColorType.white, bgColor = ColorType.white } = option;

if (typeof process === "object" && process.title === "node") {
return `\x1b[${
backgroundColor
};${textColor};1m ${type.toUpperCase()} \x1b[0m\x1b[100;97m ${text}\x1b[0m`;
return `\x1b[${backgroundColor};${textColor};1m ${type.toUpperCase()} \x1b[0m\x1b[100;97m ${text}\x1b[0m`;
} else {
return `\x1b[${
backgroundColor
};${textColor};1m ${type.toUpperCase()} \x1b[0m\x1b[100;97m ${text}`;
return `\x1b[${backgroundColor};${textColor};1m ${type.toUpperCase()} \x1b[0m\x1b[100;97m ${text}`;
}

@@ -37,3 +39,3 @@ };

text: string = "beautify-console-log ",
style: BaseColorType = { bgColor: ColorType.blue, color: ColorType.white },
style: BaseColorType = { bgColor: ColorType.blue, color: ColorType.white }
) {

@@ -44,3 +46,3 @@ return [baseColor(style, text, LogType.info)];

text: string = "beautify-console-log ",
style: BaseColorType = { bgColor: ColorType.red, color: ColorType.white },
style: BaseColorType = { bgColor: ColorType.red, color: ColorType.white }
) {

@@ -54,3 +56,3 @@ return [baseColor(style, text, LogType.error)];

color: ColorType.black,
},
}
) {

@@ -61,3 +63,3 @@ return [baseColor(style, text, LogType.warn)];

text: string = "beautify-console-log ",
style: BaseColorType = { bgColor: ColorType.green, color: ColorType.white },
style: BaseColorType = { bgColor: ColorType.green, color: ColorType.white }
) {

@@ -75,3 +77,3 @@ return [baseColor(style, text, LogType.log)];

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

@@ -88,3 +90,3 @@ * const log = BeautifyConsole.getInstance();

*
*
*
* ```

@@ -98,3 +100,3 @@ * {

* config(config: {
* type?: LogType[];
* type?: LogType[] | ('info' | 'log' | 'warn' | 'error')[];
* title?: string;

@@ -117,5 +119,17 @@ * }): void;

/**
* Print info type information
*/
info = console.info.bind(this, ...this.infoPadStartText);
/**
* Print error type information
*/
error = console.error.bind(this, ...this.errorPadStartText);
/**
* Print warn type information
*/
warn = console.warn.bind(this, ...this.warnPadStartText);
/**
* Print log type information
*/
log = console.log.bind(this, ...this.logPadStartText);

@@ -125,3 +139,6 @@

public static getInstance(): BeautifyConsole {
/**
* Singleton mode
*/ public static getInstance(): BeautifyConsole {
if (!this.instance) {

@@ -134,4 +151,6 @@ this.instance = new BeautifyConsole();

* 初始化配置项
* @param config 是否打印日志 type { BaseConfig: {type?: LogType[] | ('info' | 'log' | 'warn' | 'error')[]; title?: string} }
* 如果配置了type,就只显示配置的日志类型
*/
public config(config: { type?: LogType[]; title?: string }) {
public config(config: BaseConfig) {
const {

@@ -150,3 +169,3 @@ type = [LogType.info, LogType.error, LogType.warn, LogType.log],

title,
}),
})
);

@@ -159,5 +178,8 @@ }

* @param showLog 是否打印日志 type { boolean }
* @param type 需要设置的日志类型日志 type { LogType }
* @param type 需要设置的日志类型日志 type { LogType | 'info' | 'log' | 'warn' | 'error' }
*/
private setShowLog(showLog: boolean, type?: LogType) {
private setShowLog(
showLog: boolean,
type?: LogType | "info" | "log" | "warn" | "error"
) {
const setShowLogFunction = {

@@ -210,4 +232,2 @@ info: () => {

*
* @param type 需要设置的日志类型日志 type { LogType }
*
* @returns BeautifyConsole

@@ -223,7 +243,9 @@ */

*
* @param type 需要设置的日志类型日志 type { LogType }
* @param type 需要设置的日志类型日志 type { LogType | 'info' | 'log' | 'warn' | 'error' }
*
* @returns BeautifyConsole
*/
public open(type?: LogType): BeautifyConsole {
public open(
type?: LogType | "info" | "log" | "warn" | "error"
): BeautifyConsole {
this.setShowLog(true, type);

@@ -236,7 +258,9 @@ return this;

*
* @param type 需要设置的日志类型日志 type { LogType }
* @param type 需要设置的日志类型日志 type { LogType | 'info' | 'log' | 'warn' | 'error' }
*
* @returns BeautifyConsole
*/
public close(type?: LogType): BeautifyConsole {
public close(
type?: LogType | "info" | "log" | "warn" | "error"
): BeautifyConsole {
this.setShowLog(false, type);

@@ -248,4 +272,5 @@ return this;

* 重置开始的填充文本console日志,默认如info类型的开始填充: `cbeautify-console-log info: -> `
* @param type type { consoleType }
* @param text type { any }
* @param title type { string }
* @param logType type { logType | 'info' | 'log' | 'warn' | 'error' }
* @param style type { PadStartStyle }
* @returns BeautifyConsole

@@ -259,3 +284,3 @@ */

this,
...padText[LogType.info](config.title, config.style),
...padText[LogType.info](config.title, config.style)
);

@@ -266,3 +291,3 @@ },

this,
...padText[LogType.error](config.title, config.style),
...padText[LogType.error](config.title, config.style)
);

@@ -273,3 +298,3 @@ },

this,
...padText[LogType.warn](config.title, config.style),
...padText[LogType.warn](config.title, config.style)
);

@@ -280,3 +305,3 @@ },

this,
...padText[LogType.log](config.title, config.style),
...padText[LogType.log](config.title, config.style)
);

@@ -283,0 +308,0 @@ },

/**
* 基础配置
* ```text
* {
* type?: LogType[] | ('info' | 'log' | 'warn' | 'error')[];
* title?: string;
* }
* ```
*/
export interface BaseConfig {
type?: LogType[] | ('info' | 'log' | 'warn' | 'error')[]
title?: string
}
/**
* 背景编号:

@@ -85,3 +98,3 @@ *

* title: string;
* logType: LogType;
* logType: LogType | 'info' | 'log' | 'warn' | 'error';
* style?: PadStartStyle;

@@ -93,3 +106,3 @@ * }

title: string;
logType: LogType;
logType: LogType | 'info' | 'log' | 'warn' | 'error';
style?: PadStartStyle;

@@ -96,0 +109,0 @@ }

Sorry, the diff of this file is not supported yet

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