@qqi/log 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ # MIT License
2
+
3
+ Copyright (c) <2025> <🥜>
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
17
+ # MIT 许可证
18
+
19
+ 版权所有 (c) [2025] [🥜]
20
+
21
+ 特此免费授予任何获得本软件及相关文档文件(以下简称“软件”)副本的人不受限制地处置该软件的权利,包括不受限制地使用、复制、修改、合并、发布、分发、再许可和/或出售该软件副本的权利,并允许向其提供该软件的人这样做,但须遵守以下条件:
22
+
23
+ 上述版权声明和本许可声明应包含在所有副本或软件的重要部分中。
24
+
25
+ 软件按“原样”提供,不附带任何形式的明示或暗示的保证,包括但不限于适销性、特定用途适用性和不侵权的保证。在任何情况下,作者或版权持有人均不对因合同、侵权或其他方式引起的任何索赔、损害或其他责任负责,无论是在与软件或软件的使用或其他交易有关的任何诉讼中。
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # @qqi/log
2
+
3
+ [![version](<https://img.shields.io/npm/v/@qqi/log.svg?logo=npm&logoColor=rgb(0,0,0)&label=版本号&labelColor=rgb(73,73,228)&color=rgb(0,0,0)>)](https://www.npmjs.com/package/@qqi/log) [![issues 提交](<https://img.shields.io/badge/issues-提交-rgb(255,0,63)?logo=github>)](https://github.com/earthnutDev/qqi/issues)
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install --save @qqi/log
9
+ ```
10
+
11
+ ## 使用 Dog
12
+
13
+ ### 创建全局的 `dog` (dev log 的缩写,天才第一步,起名要认真) 对象
14
+
15
+ ```ts
16
+ /// 这里假设以 `a node tools` 为 `name` 的值
17
+ export const dog = new Dog({ name: 'a node tools' });
18
+ ```
19
+
20
+ ### 在需要打印日志的地方引入 `dog` 对象
21
+
22
+ ```ts
23
+ import { dog } from './dog';
24
+
25
+ dog('你好'); // 该值是否打印还依赖于环境变量中有没有配置 `dev_log_dev` 的值
26
+ ```
27
+
28
+ ### 启用配置
29
+
30
+ ```bash
31
+ # 配置 name 为 'a node tools',则使用 `a_node_tools_dev` 或 `A_NODE_TOOLS_DEV` 来启动
32
+ a_node_tools_dev=true npm run dev
33
+ ```
34
+
35
+ ## 文档地址
36
+
37
+ 参看 [https://earthnut.dev/qqi/log](https://earthnut.dev/qqi/log)
package/index.cjs ADDED
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var index = require('./src/index.cjs');
4
+
5
+
6
+
7
+ exports.Dog = index.Dog;
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { Dog } from './src';
2
+ export type { DevLogType, DevLog } from './src/type';
package/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export { Dog } from './src/index.mjs';
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "main": "index.cjs",
3
+ "module": "index.mjs",
4
+ "types": "index.d.ts",
5
+ "type": "module",
6
+ "version": "0.0.0",
7
+ "name": "@qqi/log",
8
+ "description": "原 @qqi/dev-log 中的 log 部分",
9
+ "license": "MIT",
10
+ "dependencies": {
11
+ "@color-pen/static": "^1.0.0",
12
+ "a-js-tools": "^1.0.1",
13
+ "a-type-of-js": "^1.0.2",
14
+ "color-pen": "^2.0.11"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "registry": "https://registry.npmjs.org/"
19
+ },
20
+ "files": [
21
+ "index.d.ts",
22
+ "index.mjs",
23
+ "index.cjs",
24
+ "src"
25
+ ],
26
+ "exports": {
27
+ ".": {
28
+ "import": {
29
+ "default": "./index.mjs",
30
+ "types": "./index.d.ts"
31
+ },
32
+ "require": {
33
+ "default": "./index.cjs",
34
+ "types": "./index.d.ts"
35
+ }
36
+ }
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/earthnutDev/qqi.git"
41
+ },
42
+ "author": {
43
+ "name": "🥜",
44
+ "email": "earthnut.dev@outlook.com",
45
+ "url": "https://earthnut.dev"
46
+ },
47
+ "browserslist": [
48
+ "node>=18.0.0"
49
+ ],
50
+ "engines": {
51
+ "node": ">=18.0.0"
52
+ },
53
+ "keywords": [
54
+ "log",
55
+ "qqi",
56
+ "earthnut"
57
+ ],
58
+ "homepage": "https://earthnut.dev",
59
+ "bugs": {
60
+ "url": "https://github.com/earthnutDev/qqi/issues",
61
+ "email": "earthnut.dev@outlook.com"
62
+ }
63
+ }
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ *
5
+ * 空函数
6
+ *
7
+ */
8
+ function blankCall(...str) {
9
+ }
10
+
11
+ exports.blankCall = blankCall;
@@ -0,0 +1,6 @@
1
+ /**
2
+ *
3
+ * 空函数
4
+ *
5
+ */
6
+ export declare function blankCall(...str: unknown[]): void;
@@ -0,0 +1,9 @@
1
+ /**
2
+ *
3
+ * 空函数
4
+ *
5
+ */
6
+ function blankCall(...str) {
7
+ }
8
+
9
+ export { blankCall };
package/src/index.cjs ADDED
@@ -0,0 +1,96 @@
1
+ 'use strict';
2
+
3
+ var aJsTools = require('a-js-tools');
4
+ var setType = require('./setType.cjs');
5
+ var blankCall = require('./blankCall.cjs');
6
+ var managePrint = require('./managePrint.cjs');
7
+ var aTypeOfJs = require('a-type-of-js');
8
+ var platform = require('./platform.cjs');
9
+ var _static = require('@color-pen/static');
10
+
11
+ /**
12
+ *
13
+ * 创建 dev log 工厂函数
14
+ *
15
+ * @param options - 配置项
16
+ * @returns - dev log 工厂函数
17
+ *
18
+ *
19
+ */
20
+ function Dog(options) {
21
+ let { name = '', type = false } = options || {};
22
+ // 处理 name
23
+ name = aTypeOfJs.isString(name)
24
+ ? name.trim().replace(/\s+/g, '_')
25
+ : aJsTools.getRandomString(10);
26
+ const _env = (platform.platform === 'node' &&
27
+ (process.env[name.toUpperCase().concat('_DEV')] ??
28
+ process.env[name.toLowerCase().concat('_dev')])) ||
29
+ false;
30
+ const env = aTypeOfJs.isUndefined(_env) || _env === 'false'
31
+ ? false
32
+ : _env === 'true'
33
+ ? true
34
+ : _env;
35
+ /** 私有属性 */
36
+ type = setType.setType(env ?? type);
37
+ /// 原始的调用方法,在 type 值变化时会触发该值的更替
38
+ // 私有方法 error
39
+ const _privateFunc = {
40
+ error: blankCall.blankCall,
41
+ warn: blankCall.blankCall,
42
+ info: blankCall.blankCall,
43
+ };
44
+ managePrint.managePrint(type, _privateFunc, name);
45
+ /** 本体方法 */
46
+ const dog = (...str) => {
47
+ Reflect.apply(_privateFunc.info, this, str);
48
+ };
49
+ // 设置 prototype
50
+ Object.setPrototypeOf(dog, this);
51
+ // 设置属性和方法
52
+ Object.defineProperties(this, {
53
+ type: {
54
+ get() {
55
+ return type || false;
56
+ },
57
+ set(type) {
58
+ const new_type = setType.setType(type);
59
+ if (new_type !== type) {
60
+ type = new_type;
61
+ managePrint.managePrint(new_type, _privateFunc, name);
62
+ }
63
+ },
64
+ },
65
+ error: {
66
+ value: (...str) => Reflect.apply(_privateFunc.error, this, str),
67
+ configurable: false,
68
+ enumerable: false,
69
+ writable: false,
70
+ },
71
+ warn: {
72
+ value: (...str) => Reflect.apply(_privateFunc.warn, this, str),
73
+ configurable: false,
74
+ enumerable: false,
75
+ writable: false,
76
+ },
77
+ });
78
+ return dog;
79
+ }
80
+ Dog.prototype.clear = () => {
81
+ if (platform.platform === 'browser') {
82
+ console.clear();
83
+ }
84
+ else {
85
+ console.log(_static.esc.concat('c'));
86
+ }
87
+ };
88
+ /**
89
+ *
90
+ * @param options 配置项
91
+ * @returns 函数对象
92
+ *
93
+ */
94
+ const DogConstructor = aJsTools.createConstructor(Dog);
95
+
96
+ exports.Dog = DogConstructor;
package/src/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { DevLog, DogOptions } from './type';
2
+ /**
3
+ *
4
+ * @param options 配置项
5
+ * @returns 函数对象
6
+ *
7
+ */
8
+ declare const DogConstructor: import("a-js-tools").CreateConstructor<DevLog, [options?: DogOptions | undefined]>;
9
+ export { DogConstructor as Dog };
package/src/index.mjs ADDED
@@ -0,0 +1,94 @@
1
+ import { createConstructor, getRandomString } from 'a-js-tools';
2
+ import { setType } from './setType.mjs';
3
+ import { blankCall } from './blankCall.mjs';
4
+ import { managePrint } from './managePrint.mjs';
5
+ import { isString, isUndefined } from 'a-type-of-js';
6
+ import { platform } from './platform.mjs';
7
+ import { esc } from '@color-pen/static';
8
+
9
+ /**
10
+ *
11
+ * 创建 dev log 工厂函数
12
+ *
13
+ * @param options - 配置项
14
+ * @returns - dev log 工厂函数
15
+ *
16
+ *
17
+ */
18
+ function Dog(options) {
19
+ let { name = '', type = false } = options || {};
20
+ // 处理 name
21
+ name = isString(name)
22
+ ? name.trim().replace(/\s+/g, '_')
23
+ : getRandomString(10);
24
+ const _env = (platform === 'node' &&
25
+ (process.env[name.toUpperCase().concat('_DEV')] ??
26
+ process.env[name.toLowerCase().concat('_dev')])) ||
27
+ false;
28
+ const env = isUndefined(_env) || _env === 'false'
29
+ ? false
30
+ : _env === 'true'
31
+ ? true
32
+ : _env;
33
+ /** 私有属性 */
34
+ type = setType(env ?? type);
35
+ /// 原始的调用方法,在 type 值变化时会触发该值的更替
36
+ // 私有方法 error
37
+ const _privateFunc = {
38
+ error: blankCall,
39
+ warn: blankCall,
40
+ info: blankCall,
41
+ };
42
+ managePrint(type, _privateFunc, name);
43
+ /** 本体方法 */
44
+ const dog = (...str) => {
45
+ Reflect.apply(_privateFunc.info, this, str);
46
+ };
47
+ // 设置 prototype
48
+ Object.setPrototypeOf(dog, this);
49
+ // 设置属性和方法
50
+ Object.defineProperties(this, {
51
+ type: {
52
+ get() {
53
+ return type || false;
54
+ },
55
+ set(type) {
56
+ const new_type = setType(type);
57
+ if (new_type !== type) {
58
+ type = new_type;
59
+ managePrint(new_type, _privateFunc, name);
60
+ }
61
+ },
62
+ },
63
+ error: {
64
+ value: (...str) => Reflect.apply(_privateFunc.error, this, str),
65
+ configurable: false,
66
+ enumerable: false,
67
+ writable: false,
68
+ },
69
+ warn: {
70
+ value: (...str) => Reflect.apply(_privateFunc.warn, this, str),
71
+ configurable: false,
72
+ enumerable: false,
73
+ writable: false,
74
+ },
75
+ });
76
+ return dog;
77
+ }
78
+ Dog.prototype.clear = () => {
79
+ if (platform === 'browser') {
80
+ console.clear();
81
+ }
82
+ else {
83
+ console.log(esc.concat('c'));
84
+ }
85
+ };
86
+ /**
87
+ *
88
+ * @param options 配置项
89
+ * @returns 函数对象
90
+ *
91
+ */
92
+ const DogConstructor = createConstructor(Dog);
93
+
94
+ export { DogConstructor as Dog };
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ var aTypeOfJs = require('a-type-of-js');
4
+ var notSupport = require('./notSupport.cjs');
5
+ var platform = require('./platform.cjs');
6
+ var blankCall = require('./blankCall.cjs');
7
+ var printError = require('./printError.cjs');
8
+ var printWarn = require('./printWarn.cjs');
9
+ var printInfo = require('./printInfo.cjs');
10
+ var setType = require('./setType.cjs');
11
+
12
+ /** 管理是否打印 */
13
+ function managePrint(type, privateFunc, name) {
14
+ if (platform.platform === 'node') {
15
+ const dev = process.env[name.toUpperCase().concat('_DEV')] ||
16
+ process.env[name.toLowerCase().concat('_dev')];
17
+ /// 当前禁止使用打印
18
+ /// node 环境未配置 NAME_DEV 环境变量
19
+ /// 显式配置 NAME_DEV 环境变量为 false
20
+ if (type === false || aTypeOfJs.isUndefined(dev) || dev === 'false') {
21
+ return Reflect.apply(notSupport.notSupport, privateFunc, []);
22
+ }
23
+ /// 将显示配置环境变量的值给 type
24
+ if ([...setType.typeList, 'true', 'false'].includes(dev)) {
25
+ type = dev === 'true' ? 'all' : dev;
26
+ }
27
+ privateFunc.info = ['all', 'info', true].includes(type)
28
+ ? printInfo.printInfo
29
+ : blankCall.blankCall;
30
+ privateFunc.error = ['all', 'error', true].includes(type)
31
+ ? printError.printError
32
+ : blankCall.blankCall;
33
+ privateFunc.warn = ['all', 'warn', true].includes(type)
34
+ ? printWarn.printWarn
35
+ : blankCall.blankCall;
36
+ }
37
+ // 在 非 node 环境始终执行,搭配 @qqi/babel-plugin-remove-dog-calls 使用
38
+ else {
39
+ privateFunc.info = printInfo.printInfo;
40
+ privateFunc.warn = printWarn.printWarn;
41
+ privateFunc.error = printError.printError;
42
+ }
43
+ }
44
+
45
+ exports.managePrint = managePrint;
@@ -0,0 +1,3 @@
1
+ import { DevLogType, PrivateFunc } from './type';
2
+ /** 管理是否打印 */
3
+ export declare function managePrint(type: DevLogType, privateFunc: PrivateFunc, name: string): void;
@@ -0,0 +1,43 @@
1
+ import { isUndefined } from 'a-type-of-js';
2
+ import { notSupport } from './notSupport.mjs';
3
+ import { platform } from './platform.mjs';
4
+ import { blankCall } from './blankCall.mjs';
5
+ import { printError } from './printError.mjs';
6
+ import { printWarn } from './printWarn.mjs';
7
+ import { printInfo } from './printInfo.mjs';
8
+ import { typeList } from './setType.mjs';
9
+
10
+ /** 管理是否打印 */
11
+ function managePrint(type, privateFunc, name) {
12
+ if (platform === 'node') {
13
+ const dev = process.env[name.toUpperCase().concat('_DEV')] ||
14
+ process.env[name.toLowerCase().concat('_dev')];
15
+ /// 当前禁止使用打印
16
+ /// node 环境未配置 NAME_DEV 环境变量
17
+ /// 显式配置 NAME_DEV 环境变量为 false
18
+ if (type === false || isUndefined(dev) || dev === 'false') {
19
+ return Reflect.apply(notSupport, privateFunc, []);
20
+ }
21
+ /// 将显示配置环境变量的值给 type
22
+ if ([...typeList, 'true', 'false'].includes(dev)) {
23
+ type = dev === 'true' ? 'all' : dev;
24
+ }
25
+ privateFunc.info = ['all', 'info', true].includes(type)
26
+ ? printInfo
27
+ : blankCall;
28
+ privateFunc.error = ['all', 'error', true].includes(type)
29
+ ? printError
30
+ : blankCall;
31
+ privateFunc.warn = ['all', 'warn', true].includes(type)
32
+ ? printWarn
33
+ : blankCall;
34
+ }
35
+ // 在 非 node 环境始终执行,搭配 @qqi/babel-plugin-remove-dog-calls 使用
36
+ else {
37
+ privateFunc.info = printInfo;
38
+ privateFunc.warn = printWarn;
39
+ privateFunc.error = printError;
40
+ }
41
+ }
42
+
43
+ export { managePrint };
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var blankCall = require('./blankCall.cjs');
4
+
5
+ /**
6
+ * 当前环境不支持
7
+ *
8
+ * 三个方法都是空方法
9
+ */
10
+ function notSupport() {
11
+ this.error = this.info = this.warn = blankCall.blankCall;
12
+ }
13
+
14
+ exports.notSupport = notSupport;
@@ -0,0 +1,7 @@
1
+ import { PrivateFunc } from './type';
2
+ /**
3
+ * 当前环境不支持
4
+ *
5
+ * 三个方法都是空方法
6
+ */
7
+ export declare function notSupport(this: PrivateFunc): void;
@@ -0,0 +1,12 @@
1
+ import { blankCall } from './blankCall.mjs';
2
+
3
+ /**
4
+ * 当前环境不支持
5
+ *
6
+ * 三个方法都是空方法
7
+ */
8
+ function notSupport() {
9
+ this.error = this.info = this.warn = blankCall;
10
+ }
11
+
12
+ export { notSupport };
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ var colorPen = require('color-pen');
4
+
5
+ /**
6
+ *
7
+ * 解析 error
8
+ *
9
+ */
10
+ function parseError(type) {
11
+ try {
12
+ throw new Error();
13
+ }
14
+ catch (error) {
15
+ const parseErrorResult = (error.stack?.split('\n') || []).map(item => {
16
+ const reg = /at\s(.*)\s\((.*):(\d*):(\d*)\)/;
17
+ const res = reg.exec(item);
18
+ if (res) {
19
+ return {
20
+ name: res[1],
21
+ path: res[2],
22
+ line: res[3],
23
+ column: res[4],
24
+ };
25
+ }
26
+ return {
27
+ name: '',
28
+ };
29
+ });
30
+ const result = parseErrorResult.filter(e => e.name !== '' && e.path !== undefined);
31
+ const res = result[3] ?? result[2] ?? result[1] ?? result[0];
32
+ const startStr = ` ${type === 'info' ? '💡' : type === 'error' ? '❌' : '⚠️ '} ${new Date().toLocaleString()} `;
33
+ const printStartPenStr = (type === 'info'
34
+ ? colorPen.pen.bgCyan.brightWhite
35
+ : type === 'error'
36
+ ? colorPen.pen.bgBlack.red
37
+ : colorPen.pen.bgBrightYellow.brightGreen)(startStr);
38
+ console.log(`${printStartPenStr} ${res?.name ?? ''} ${res?.line?.concat(' 行')} ${res?.column?.concat(' 列')}`);
39
+ }
40
+ }
41
+
42
+ exports.parseError = parseError;
@@ -0,0 +1,7 @@
1
+ import { DevLogType } from './type';
2
+ /**
3
+ *
4
+ * 解析 error
5
+ *
6
+ */
7
+ export declare function parseError(type: DevLogType): void;
@@ -0,0 +1,40 @@
1
+ import { pen } from 'color-pen';
2
+
3
+ /**
4
+ *
5
+ * 解析 error
6
+ *
7
+ */
8
+ function parseError(type) {
9
+ try {
10
+ throw new Error();
11
+ }
12
+ catch (error) {
13
+ const parseErrorResult = (error.stack?.split('\n') || []).map(item => {
14
+ const reg = /at\s(.*)\s\((.*):(\d*):(\d*)\)/;
15
+ const res = reg.exec(item);
16
+ if (res) {
17
+ return {
18
+ name: res[1],
19
+ path: res[2],
20
+ line: res[3],
21
+ column: res[4],
22
+ };
23
+ }
24
+ return {
25
+ name: '',
26
+ };
27
+ });
28
+ const result = parseErrorResult.filter(e => e.name !== '' && e.path !== undefined);
29
+ const res = result[3] ?? result[2] ?? result[1] ?? result[0];
30
+ const startStr = ` ${type === 'info' ? '💡' : type === 'error' ? '❌' : '⚠️ '} ${new Date().toLocaleString()} `;
31
+ const printStartPenStr = (type === 'info'
32
+ ? pen.bgCyan.brightWhite
33
+ : type === 'error'
34
+ ? pen.bgBlack.red
35
+ : pen.bgBrightYellow.brightGreen)(startStr);
36
+ console.log(`${printStartPenStr} ${res?.name ?? ''} ${res?.line?.concat(' 行')} ${res?.column?.concat(' 列')}`);
37
+ }
38
+ }
39
+
40
+ export { parseError };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var aJsTools = require('a-js-tools');
4
+
5
+ const platform = aJsTools.isNode() ? 'node' : 'browser';
6
+
7
+ exports.platform = platform;
@@ -0,0 +1 @@
1
+ export declare const platform: string;
@@ -0,0 +1,5 @@
1
+ import { isNode } from 'a-js-tools';
2
+
3
+ const platform = isNode() ? 'node' : 'browser';
4
+
5
+ export { platform };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var parseError = require('./parseError.cjs');
4
+
5
+ /**
6
+ *
7
+ * 打印 error 信息
8
+ *
9
+ */
10
+ function printError(...str) {
11
+ parseError.parseError('error');
12
+ console.error(...str);
13
+ }
14
+
15
+ exports.printError = printError;
@@ -0,0 +1,6 @@
1
+ /**
2
+ *
3
+ * 打印 error 信息
4
+ *
5
+ */
6
+ export declare function printError(...str: unknown[]): void;
@@ -0,0 +1,13 @@
1
+ import { parseError } from './parseError.mjs';
2
+
3
+ /**
4
+ *
5
+ * 打印 error 信息
6
+ *
7
+ */
8
+ function printError(...str) {
9
+ parseError('error');
10
+ console.error(...str);
11
+ }
12
+
13
+ export { printError };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var parseError = require('./parseError.cjs');
4
+
5
+ /**
6
+ *
7
+ * 打印 info 消息
8
+ *
9
+ */
10
+ function printInfo(...str) {
11
+ parseError.parseError('info');
12
+ console.info(...str);
13
+ }
14
+
15
+ exports.printInfo = printInfo;
@@ -0,0 +1,6 @@
1
+ /**
2
+ *
3
+ * 打印 info 消息
4
+ *
5
+ */
6
+ export declare function printInfo(...str: unknown[]): void;
@@ -0,0 +1,13 @@
1
+ import { parseError } from './parseError.mjs';
2
+
3
+ /**
4
+ *
5
+ * 打印 info 消息
6
+ *
7
+ */
8
+ function printInfo(...str) {
9
+ parseError('info');
10
+ console.info(...str);
11
+ }
12
+
13
+ export { printInfo };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var parseError = require('./parseError.cjs');
4
+
5
+ /**
6
+ *
7
+ * 打印 warn 信息
8
+ *
9
+ */
10
+ function printWarn(...str) {
11
+ parseError.parseError('warn');
12
+ console.warn(...str);
13
+ }
14
+
15
+ exports.printWarn = printWarn;
@@ -0,0 +1,6 @@
1
+ /**
2
+ *
3
+ * 打印 warn 信息
4
+ *
5
+ */
6
+ export declare function printWarn(...str: unknown[]): void;
@@ -0,0 +1,13 @@
1
+ import { parseError } from './parseError.mjs';
2
+
3
+ /**
4
+ *
5
+ * 打印 warn 信息
6
+ *
7
+ */
8
+ function printWarn(...str) {
9
+ parseError('warn');
10
+ console.warn(...str);
11
+ }
12
+
13
+ export { printWarn };
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ const typeList = [
4
+ false,
5
+ true,
6
+ 'all',
7
+ 'info',
8
+ 'error',
9
+ 'warn',
10
+ ];
11
+ /**
12
+ * 设置 type 的类型
13
+ */
14
+ function setType(type) {
15
+ if (typeList.includes(type))
16
+ return type;
17
+ return false;
18
+ }
19
+
20
+ exports.setType = setType;
21
+ exports.typeList = typeList;
@@ -0,0 +1,6 @@
1
+ import { DevLogType } from './type';
2
+ export declare const typeList: DevLogType[];
3
+ /**
4
+ * 设置 type 的类型
5
+ */
6
+ export declare function setType(type: DevLogType): DevLogType;
@@ -0,0 +1,18 @@
1
+ const typeList = [
2
+ false,
3
+ true,
4
+ 'all',
5
+ 'info',
6
+ 'error',
7
+ 'warn',
8
+ ];
9
+ /**
10
+ * 设置 type 的类型
11
+ */
12
+ function setType(type) {
13
+ if (typeList.includes(type))
14
+ return type;
15
+ return false;
16
+ }
17
+
18
+ export { setType, typeList };
package/src/type.d.ts ADDED
@@ -0,0 +1,36 @@
1
+ export type DevLogType = boolean | 'info' | 'error' | 'all' | 'warn';
2
+ export type DevLog = {
3
+ /** 打印信息本当作为 info 信息,在 type 为 `false`、`error`、`warn` 时不打印 */
4
+ (...str: unknown[]): void;
5
+ /** 当打印的版本为错误信息,在 type 为 `false`、`info`、`warn` 时不打印 */
6
+ error: (...str: unknown[]) => void;
7
+ /** 当打印的版本为警示信息,在 type 为 `false`、`info`、`error` 时不打印 */
8
+ warn: (...str: unknown[]) => void;
9
+ /** node 平台执行依据 */
10
+ name: '';
11
+ /** 开启打印的类型 */
12
+ type: DevLogType;
13
+ /** 清除控制台 */
14
+ clear: () => void;
15
+ };
16
+ export type platform = 'node' | 'browser';
17
+ export interface PrivateFunc {
18
+ error: (...str: unknown[]) => void;
19
+ warn: (...str: unknown[]) => void;
20
+ info: (...str: unknown[]) => void;
21
+ }
22
+ export type DogOptions = {
23
+ /**
24
+ * ### 类型
25
+ *
26
+ * 但是该值将被传入的系统参数覆盖
27
+ *
28
+ */
29
+ type?: DevLogType;
30
+ /**
31
+ * 该值将以 name_dev 的形式配置允许打印
32
+ *
33
+ *
34
+ */
35
+ name?: string;
36
+ };