@anjianshi/utils 1.0.1 → 1.0.4
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/env-node/logging.d.ts +5 -6
- package/logging/adapt.d.ts +1 -1
- package/logging/adapt.js +1 -2
- package/package.json +2 -1
- package/src/logging/adapt.ts +1 -2
package/env-node/logging.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
1
|
import { type Logger, type LogInfo, LogHandler } from '../logging/index.js';
|
|
3
2
|
export * from '../logging/index.js';
|
|
4
3
|
/**
|
|
@@ -25,14 +24,14 @@ export declare class ConsoleHandler extends LogHandler {
|
|
|
25
24
|
};
|
|
26
25
|
};
|
|
27
26
|
static readonly levelColors: {
|
|
28
|
-
1: chalk.
|
|
29
|
-
2: chalk.
|
|
30
|
-
3: chalk.
|
|
31
|
-
4: chalk.
|
|
27
|
+
1: import("chalk").ChalkInstance;
|
|
28
|
+
2: import("chalk").ChalkInstance;
|
|
29
|
+
3: import("chalk").ChalkInstance;
|
|
30
|
+
4: import("chalk").ChalkInstance;
|
|
32
31
|
};
|
|
33
32
|
private static readonly loggerColors;
|
|
34
33
|
private static readonly loggerColorMap;
|
|
35
|
-
static getLoggerColor(logger: string): "green" | "yellow" | "blue" | "
|
|
34
|
+
static getLoggerColor(logger: string): "green" | "yellow" | "blue" | "cyan" | "magenta" | "greenBright" | "yellowBright" | "blueBright" | "cyanBright" | "magentaBright";
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
38
37
|
* 写入文件日志
|
package/logging/adapt.d.ts
CHANGED
package/logging/adapt.js
CHANGED
|
@@ -2,7 +2,7 @@ import { getLogger } from './index.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* 适配 debug package
|
|
4
4
|
*/
|
|
5
|
-
export function adaptDebugLib(debugLib, enable = '') {
|
|
5
|
+
export function adaptDebugLib(debugLib, enable = '', logger = getLogger('3rd-library')) {
|
|
6
6
|
// 不在 localStorage 里记录 debugLib enable 状态,
|
|
7
7
|
// 以解决 web worker 里读不到 localStorage 而无法启用 debugLib 日志的问题
|
|
8
8
|
const emulate = {
|
|
@@ -30,7 +30,6 @@ export function adaptDebugLib(debugLib, enable = '') {
|
|
|
30
30
|
};
|
|
31
31
|
Object.assign(debugLib, emulate);
|
|
32
32
|
// 将 debugLib 日志转发给 logger
|
|
33
|
-
const logger = getLogger('3rd-library');
|
|
34
33
|
debugLib.log = logger.debug.bind(logger);
|
|
35
34
|
if (enable) {
|
|
36
35
|
debugLib.enable(enable);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anjianshi/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Common JavaScript Utils",
|
|
5
5
|
"homepage": "https://github.com/anjianshi/js-utils",
|
|
6
6
|
"bugs": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"main": "index.js",
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"chalk": "^5.3.0",
|
|
28
29
|
"dayjs": "^1.11.10",
|
|
29
30
|
"lodash": "^4.17.21"
|
|
30
31
|
},
|
package/src/logging/adapt.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { getLogger } from './index.js'
|
|
|
4
4
|
/**
|
|
5
5
|
* 适配 debug package
|
|
6
6
|
*/
|
|
7
|
-
export function adaptDebugLib(debugLib: Debug, enable = '') {
|
|
7
|
+
export function adaptDebugLib(debugLib: Debug, enable = '', logger = getLogger('3rd-library')) {
|
|
8
8
|
// 不在 localStorage 里记录 debugLib enable 状态,
|
|
9
9
|
// 以解决 web worker 里读不到 localStorage 而无法启用 debugLib 日志的问题
|
|
10
10
|
const emulate = {
|
|
@@ -31,7 +31,6 @@ export function adaptDebugLib(debugLib: Debug, enable = '') {
|
|
|
31
31
|
Object.assign(debugLib, emulate)
|
|
32
32
|
|
|
33
33
|
// 将 debugLib 日志转发给 logger
|
|
34
|
-
const logger = getLogger('3rd-library')
|
|
35
34
|
debugLib.log = logger.debug.bind(logger)
|
|
36
35
|
|
|
37
36
|
if (enable) {
|