@rife/logger 0.0.6-beta.12 → 0.0.6-beta.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rife/logger",
3
- "version": "0.0.6-beta.12",
3
+ "version": "0.0.6-beta.14",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "types": "./src/index.ts",
@@ -14,12 +14,20 @@
14
14
  "types": "./src/pino/index.ts",
15
15
  "require": "./dist/cjs/pino/index.cjs",
16
16
  "import": "./dist/esm/pino/index.mjs"
17
+ },
18
+ "./worker": {
19
+ "types": "./src/worker/index.ts",
20
+ "require": "./dist/cjs/worker/index.cjs",
21
+ "import": "./dist/esm/worker/index.mjs"
17
22
  }
18
23
  },
19
24
  "typesVersions": {
20
25
  "*": {
21
26
  "pino": [
22
27
  "./src/pino"
28
+ ],
29
+ "worker": [
30
+ "./src/worker"
23
31
  ]
24
32
  }
25
33
  },
@@ -29,15 +37,15 @@
29
37
  "tsconfig.json"
30
38
  ],
31
39
  "dependencies": {
32
- "pino": "^10.1.0",
40
+ "pino": "^10.3.1",
33
41
  "pino-pretty": "^13.1.3",
34
- "pino-std-serializers": "^7.0.0",
35
- "rotating-file-stream": "^3.2.7"
42
+ "pino-std-serializers": "^7.1.0",
43
+ "rotating-file-stream": "^3.2.9"
36
44
  },
37
45
  "devDependencies": {
38
46
  "thread-stream": "^4.0.0",
39
- "@rife/cli": "0.0.6-beta.20",
40
- "@rife/plugin-rstack": "0.0.1-beta.17"
47
+ "@rife/plugin-rstack": "0.0.1-beta.23",
48
+ "@rife/cli": "0.0.6-beta.22"
41
49
  },
42
50
  "scripts": {
43
51
  "dev": "rife dev",
package/src/pino/index.ts CHANGED
@@ -2,6 +2,10 @@ import path from 'path';
2
2
 
3
3
  import pino from 'pino';
4
4
 
5
+ export { pino };
6
+ // 避免报错 "This is likely not portable. A type annotation is necessary."
7
+ export type { Logger } from 'pino';
8
+
5
9
  import { genTraceId, getTraceId, runInTrace } from '../trace';
6
10
 
7
11
  declare var __isNodeSingleFileBundle: any;
@@ -12,6 +16,7 @@ function getPinoConfig() {
12
16
  const targets: any = [];
13
17
 
14
18
  const rotate = `./rotate${path.extname(__filename)}`;
19
+
15
20
  targets.push({
16
21
  level: 'debug',
17
22
  target: rotate,
@@ -52,7 +57,7 @@ function getPinoConfig() {
52
57
  transport: { targets },
53
58
  mixin(data: any) {
54
59
  // {"level":30,"time":1726065716643,"pid":21968,"hostname":"Win-LH"}
55
- // 基础字段不能重复 删除掉
60
+ // 基础字段不能重复
56
61
  const traceId = data?.traceId;
57
62
  delete data.traceId;
58
63
  delete data.level;
@@ -65,6 +70,26 @@ function getPinoConfig() {
65
70
  }
66
71
  return { traceId };
67
72
  },
73
+ // cloudfare worker 需要自己实现输出
74
+ browser: {
75
+ write: (o: any) => {
76
+ // https://github.com/pinojs/pino/blob/main/docs/api.md#level-1
77
+ const { name, time, level, ...rest } = o;
78
+ if (name) {
79
+ rest.message = rest.message ? `[${name}] ${rest.message}` : `[${name}]`;
80
+ }
81
+ if (!rest.traceId) {
82
+ rest.traceId = getTraceId();
83
+ }
84
+ if (level >= 50) {
85
+ console.error(rest);
86
+ } else if (level >= 40) {
87
+ console.warn(rest);
88
+ } else {
89
+ console.log(rest);
90
+ }
91
+ },
92
+ },
68
93
  };
69
94
 
70
95
  return config;
@@ -0,0 +1,3 @@
1
+
2
+
3
+
package/tsconfig.json CHANGED
@@ -1,9 +1,7 @@
1
1
  {
2
2
  "extends": "@rife/config/tsconfig.json", // 继承 packages 目录下通用配置
3
3
  "compilerOptions": {
4
- "outDir": "dist",
5
4
  "declaration": true,
6
- "baseUrl": ".",
7
5
  "paths": {
8
6
  "@/*": ["./src/*"]
9
7
  }