@lark-apaas/client-toolkit 1.1.5-log-panel.0 → 1.1.5-logpanel-test.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.
@@ -9,7 +9,16 @@ const NotFound = ()=>{
9
9
  const navigate = useNavigate();
10
10
  const navigateRef = useUpdatingRef(navigate);
11
11
  useEffect(()=>{
12
- logger.error('404 Error: User attempted to access non-existent route:', location.pathname);
12
+ logger.log({
13
+ level: 'error',
14
+ args: [
15
+ `页面 ${location.pathname} 不存在`
16
+ ],
17
+ meta: {
18
+ repairMessage: `页面 ${location.pathname} 不存在,帮我创建`,
19
+ noStacktrace: true
20
+ }
21
+ });
13
22
  }, [
14
23
  location.pathname
15
24
  ]);
@@ -42,8 +42,10 @@ export declare const logMeta: z.ZodObject<{
42
42
  }, z.core.$strip>>>;
43
43
  logTraceID: z.ZodOptional<z.ZodString>;
44
44
  skipFrame: z.ZodOptional<z.ZodNumber>;
45
+ noStacktrace: z.ZodOptional<z.ZodBoolean>;
46
+ repairMessage: z.ZodOptional<z.ZodString>;
45
47
  }, z.core.$strip>;
46
- export declare const selectedLogSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
48
+ export declare const selectedLogSchema: z.ZodObject<{
47
49
  type: z.ZodLiteral<"typedLogV2">;
48
50
  level: z.ZodEnum<{
49
51
  success: "success";
@@ -63,8 +65,10 @@ export declare const selectedLogSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
63
65
  }, z.core.$strip>>>;
64
66
  logTraceID: z.ZodOptional<z.ZodString>;
65
67
  skipFrame: z.ZodOptional<z.ZodNumber>;
68
+ noStacktrace: z.ZodOptional<z.ZodBoolean>;
69
+ repairMessage: z.ZodOptional<z.ZodString>;
66
70
  }, z.core.$strip>;
67
- }, z.core.$strip>], "type">;
71
+ }, z.core.$strip>;
68
72
  export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'success';
69
73
  export declare const logWithMetaSchema: z.ZodObject<{
70
74
  level: z.ZodEnum<{
@@ -84,6 +88,8 @@ export declare const logWithMetaSchema: z.ZodObject<{
84
88
  }, z.core.$strip>>>;
85
89
  logTraceID: z.ZodOptional<z.ZodString>;
86
90
  skipFrame: z.ZodOptional<z.ZodNumber>;
91
+ noStacktrace: z.ZodOptional<z.ZodBoolean>;
92
+ repairMessage: z.ZodOptional<z.ZodString>;
87
93
  }, z.core.$strip>;
88
94
  }, z.core.$strip>;
89
95
  export type LogStackFrame = z.infer<typeof logStackFrameSchema>;
@@ -36,17 +36,17 @@ const levelSchema = zod["enum"]([
36
36
  const logMeta = zod.object({
37
37
  stacktrace: zod.optional(zod.array(logStackFrameSchema)),
38
38
  logTraceID: zod.optional(zod.string()),
39
- skipFrame: zod.optional(zod.number())
40
- });
41
- const selectedLogSchema = zod.discriminatedUnion('type', [
42
- zod.object({
43
- type: zod.literal('typedLogV2'),
44
- level: levelSchema,
45
- id: zod.string(),
46
- args: zod.array(zod.unknown()),
47
- meta: logMeta
48
- })
49
- ]);
39
+ skipFrame: zod.optional(zod.number()),
40
+ noStacktrace: zod.optional(zod.boolean()),
41
+ repairMessage: zod.optional(zod.string())
42
+ });
43
+ const selectedLogSchema = zod.object({
44
+ type: zod.literal('typedLogV2'),
45
+ level: levelSchema,
46
+ id: zod.string(),
47
+ args: zod.array(zod.unknown()),
48
+ meta: logMeta
49
+ });
50
50
  const logWithMetaSchema = zod.object({
51
51
  level: levelSchema,
52
52
  args: zod.array(zod.unknown()),
@@ -43,7 +43,9 @@ async function sendSelectedLog(logWithoutID) {
43
43
  newParts.push(newError.message, newError);
44
44
  } else newParts.push(log.args[i]);
45
45
  if (!log.meta.stacktrace) {
46
- const frames = await getStacktrace();
46
+ let frames = await getStacktrace();
47
+ const firstFrameIndex = frames.findIndex((frame)=>!frame.fileName.includes('node_modules/@lark-apaas/client-toolkit/lib/logger'));
48
+ frames = -1 === firstFrameIndex ? [] : frames.slice(firstFrameIndex);
47
49
  log.meta.stacktrace = frames;
48
50
  }
49
51
  if (void 0 === log.meta.skipFrame) log.meta.skipFrame = 2;
@@ -3,12 +3,12 @@ import { logger } from "../apis/logger.js";
3
3
  import { getStacktrace } from "../logger/selected-logs.js";
4
4
  async function logResponse(ok, response) {
5
5
  const okToTextMap = {
6
- success: 'API 请求成功:',
7
- error: 'API 请求失败:'
6
+ success: '请求成功:',
7
+ error: '请求失败:'
8
8
  };
9
9
  const parts = [
10
10
  okToTextMap[ok],
11
- (response.config.url || '').split('?')[0],
11
+ (response.config.url || '').split('?')[0].replace(/^\/spark\/p\/app_\w+/, ''),
12
12
  ' - ',
13
13
  Date.now() - response.config._startTime,
14
14
  'ms'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.1.5-log-panel.0",
3
+ "version": "1.1.5-logpanel-test.0",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [