@qqi/log 1.0.0 → 1.1.1
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/README.md +10 -0
- package/cjs/core.js +142 -0
- package/cjs/index.js +5 -100
- package/cjs/util.js +87 -0
- package/cjs/virtual-dog.js +60 -0
- package/es/core.js +140 -0
- package/es/eslint.config.d.ts +1222 -0
- package/es/index.js +2 -102
- package/es/rollup.config.d.ts +17 -0
- package/es/rollup.config.eg.d.ts +14 -0
- package/es/src/core.d.ts +9 -0
- package/es/src/index.d.ts +12 -7
- package/es/src/type.d.ts +11 -9
- package/es/src/util.d.ts +35 -0
- package/es/src/virtual-dog.d.ts +16 -0
- package/es/util.js +81 -0
- package/es/virtual-dog.js +58 -0
- package/package.json +8 -2
- package/cjs/blankCall.js +0 -11
- package/cjs/managePrint.js +0 -53
- package/cjs/notSupport.js +0 -14
- package/cjs/parseError.js +0 -42
- package/cjs/platform.js +0 -7
- package/cjs/printError.js +0 -15
- package/cjs/printInfo.js +0 -15
- package/cjs/printWarn.js +0 -15
- package/cjs/setType.js +0 -21
- package/es/blankCall.js +0 -9
- package/es/managePrint.js +0 -51
- package/es/notSupport.js +0 -12
- package/es/parseError.js +0 -40
- package/es/platform.js +0 -5
- package/es/printError.js +0 -13
- package/es/printInfo.js +0 -13
- package/es/printWarn.js +0 -13
- package/es/setType.js +0 -18
- package/es/src/blankCall.d.ts +0 -6
- package/es/src/managePrint.d.ts +0 -3
- package/es/src/notSupport.d.ts +0 -7
- package/es/src/parseError.d.ts +0 -7
- package/es/src/platform.d.ts +0 -1
- package/es/src/printError.d.ts +0 -6
- package/es/src/printInfo.d.ts +0 -6
- package/es/src/printWarn.d.ts +0 -6
- package/es/src/setType.d.ts +0 -6
package/es/managePrint.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { isUndefined } from 'a-type-of-js';
|
|
2
|
-
import { notSupport } from './notSupport.js';
|
|
3
|
-
import { platform } from './platform.js';
|
|
4
|
-
import { blankCall } from './blankCall.js';
|
|
5
|
-
import { printError } from './printError.js';
|
|
6
|
-
import { printWarn } from './printWarn.js';
|
|
7
|
-
import { printInfo } from './printInfo.js';
|
|
8
|
-
import { typeList } from './setType.js';
|
|
9
|
-
|
|
10
|
-
/** 管理是否打印 */
|
|
11
|
-
function managePrint(type, privateFunc, name) {
|
|
12
|
-
if (platform === 'node') {
|
|
13
|
-
const dev = globalThis?.process.env[name.toUpperCase().concat('_DEV')] ||
|
|
14
|
-
globalThis?.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
|
-
if (type === false)
|
|
38
|
-
return Reflect.apply(notSupport, privateFunc, []);
|
|
39
|
-
privateFunc.info = ['all', 'info', true].includes(type)
|
|
40
|
-
? printInfo
|
|
41
|
-
: blankCall;
|
|
42
|
-
privateFunc.error = ['all', 'error', true].includes(type)
|
|
43
|
-
? printError
|
|
44
|
-
: blankCall;
|
|
45
|
-
privateFunc.warn = ['all', 'warn', true].includes(type)
|
|
46
|
-
? printWarn
|
|
47
|
-
: blankCall;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export { managePrint };
|
package/es/notSupport.js
DELETED
package/es/parseError.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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 };
|
package/es/platform.js
DELETED
package/es/printError.js
DELETED
package/es/printInfo.js
DELETED
package/es/printWarn.js
DELETED
package/es/setType.js
DELETED
package/es/src/blankCall.d.ts
DELETED
package/es/src/managePrint.d.ts
DELETED
package/es/src/notSupport.d.ts
DELETED
package/es/src/parseError.d.ts
DELETED
package/es/src/platform.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const platform: string;
|
package/es/src/printError.d.ts
DELETED
package/es/src/printInfo.d.ts
DELETED
package/es/src/printWarn.d.ts
DELETED