@weapp-core/logger 3.0.3 → 3.1.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/README.md +4 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +3 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
- 全局日志级别控制
|
|
10
10
|
- 按 tag 覆盖日志级别
|
|
11
11
|
- API 兼容 consola 的常用用法
|
|
12
|
+
- 内置 `picocolors`,统一终端文本染色
|
|
12
13
|
|
|
13
14
|
## 安装
|
|
14
15
|
|
|
@@ -19,7 +20,7 @@ pnpm add @weapp-core/logger
|
|
|
19
20
|
## 使用
|
|
20
21
|
|
|
21
22
|
```ts
|
|
22
|
-
import logger, { configureLogger } from '@weapp-core/logger'
|
|
23
|
+
import logger, { colors, configureLogger } from '@weapp-core/logger'
|
|
23
24
|
|
|
24
25
|
configureLogger({
|
|
25
26
|
level: 'info',
|
|
@@ -30,6 +31,8 @@ configureLogger({
|
|
|
30
31
|
|
|
31
32
|
logger.info('Hello')
|
|
32
33
|
logger.withTag('build').warn('Build warning')
|
|
34
|
+
|
|
35
|
+
logger.success(colors.green('Build done'))
|
|
33
36
|
```
|
|
34
37
|
|
|
35
38
|
## 配置
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as picocolors_types from 'picocolors/types';
|
|
1
2
|
import { ConsolaInstance } from 'consola';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -8,6 +9,12 @@ type LogType = 'error' | 'warn' | 'info';
|
|
|
8
9
|
* @description 日志级别
|
|
9
10
|
*/
|
|
10
11
|
type LogLevel = LogType | 'silent';
|
|
12
|
+
/**
|
|
13
|
+
* @description 终端文本染色工具,基于 picocolors。
|
|
14
|
+
*/
|
|
15
|
+
declare const colors: picocolors_types.Colors & {
|
|
16
|
+
createColors: (enabled?: boolean) => picocolors_types.Colors;
|
|
17
|
+
};
|
|
11
18
|
interface LoggerConfig {
|
|
12
19
|
/**
|
|
13
20
|
* @description 全局日志级别
|
|
@@ -28,4 +35,4 @@ interface LoggerConfig {
|
|
|
28
35
|
declare function configureLogger(config?: LoggerConfig): void;
|
|
29
36
|
declare const logger: ConsolaInstance;
|
|
30
37
|
|
|
31
|
-
export { type LogLevel, type LogType, type LoggerConfig, configureLogger, logger as default };
|
|
38
|
+
export { type LogLevel, type LogType, type LoggerConfig, colors, configureLogger, logger as default };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { createConsola } from "consola";
|
|
3
|
+
import picocolors from "picocolors";
|
|
4
|
+
var colors = picocolors;
|
|
3
5
|
var baseLogger = createConsola();
|
|
4
6
|
var levelRank = {
|
|
5
7
|
silent: -1,
|
|
@@ -74,6 +76,7 @@ function createLogger(tag) {
|
|
|
74
76
|
var logger = createLogger();
|
|
75
77
|
var index_default = logger;
|
|
76
78
|
export {
|
|
79
|
+
colors,
|
|
77
80
|
configureLogger,
|
|
78
81
|
index_default as default
|
|
79
82
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-core/logger",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0
|
|
4
|
+
"version": "3.1.0",
|
|
5
5
|
"description": "@weapp-core/logger",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
"node": "^20.19.0 || >=22.12.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"consola": "^3.4.2"
|
|
42
|
+
"consola": "^3.4.2",
|
|
43
|
+
"picocolors": "^1.1.1"
|
|
43
44
|
},
|
|
44
45
|
"scripts": {
|
|
45
46
|
"dev": "tsup --watch --sourcemap",
|