|
@@ -1,21 +1,58 @@
|
|
|
-
|
|
|
+import { store } from "@/store/store";
|
|
|
+import moment from "moment";
|
|
|
+import { omit } from "lodash-es";
|
|
|
+
|
|
|
type LogDetail = {
|
|
|
level?: "debug" | "log" | "warn" | "error";
|
|
|
|
|
|
cnl?: ("console" | "local" | "server" | "bd")[];
|
|
|
-
|
|
|
- pgu?: string;
|
|
|
-
|
|
|
+
|
|
|
+ key?: string;
|
|
|
+
|
|
|
+ pgn?: string;
|
|
|
+
|
|
|
+ pgu?: "AUTO" | `/${string}`;
|
|
|
+
|
|
|
+ act?: string;
|
|
|
+
|
|
|
stk?: string;
|
|
|
|
|
|
dtl?: string;
|
|
|
-
|
|
|
+
|
|
|
+ aul?: string;
|
|
|
+
|
|
|
+ aus?: string;
|
|
|
+
|
|
|
+ ejn?: string;
|
|
|
+
|
|
|
ext?: any;
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
+ * 示例:
|
|
|
+ * @param detail.key - '本地人脸比对'
|
|
|
+ * @param detail.pgn - '登录页面' | '在线考试列表页面'
|
|
|
+ * @param detail.act - '点击登录按钮'
|
|
|
+ * @param detail.stk - error.stack
|
|
|
+ * @param detail.dtl - '第一次点击登录' | '第二次点击登录'
|
|
|
+ * @param detail.aul - '/api/login'
|
|
|
+ * @param detail.aus - '500'
|
|
|
+ * @param detail.ejn - JSON.stringify({a: 0})
|
|
|
+ * @param detail.ext - {UA: 'chrome 99'}
|
|
|
+ */
|
|
|
export default function (detail: LogDetail) {
|
|
|
- const newDetail = Object.assign({ level: "log" }, detail);
|
|
|
- if (newDetail.cnl?.includes("console")) {
|
|
|
+ const user = store.user;
|
|
|
+ const defaultFileds = {
|
|
|
+ level: "log",
|
|
|
+ uuidForEcs: localStorage.getItem("uuidForEcs"),
|
|
|
+ clientDate: moment().format("YYYY-MM-DD HH:mm:ss.SSS"),
|
|
|
+ ...(user?.id ? { userId: user.id } : {}),
|
|
|
+ };
|
|
|
+ const newDetail = Object.assign(
|
|
|
+ defaultFileds,
|
|
|
+ omit(detail, "ext"),
|
|
|
+ detail.ext
|
|
|
+ );
|
|
|
+ if (detail.cnl?.includes("console")) {
|
|
|
console.log(newDetail);
|
|
|
}
|
|
|
}
|