@pisell/core 1.1.3 → 1.1.5

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.
@@ -81,10 +81,10 @@ declare class LoggerManager {
81
81
  private createFileName;
82
82
  /**
83
83
  * 创建AWS日志文件名
84
- * @param isManual 是否手动上传
84
+ * @param isManual 紧急上传
85
85
  * @returns 日志文件名
86
86
  */
87
- createAWSFileName(isManual?: boolean): Promise<any>;
87
+ createAWSFileName(urgent?: boolean): Promise<any>;
88
88
  /**
89
89
  * 创建日志文件
90
90
  * @param _fileName 文件名
@@ -94,7 +94,7 @@ declare class LoggerManager {
94
94
  /**
95
95
  * 存储日志到持久化存储
96
96
  */
97
- storeLog(): Promise<void>;
97
+ storeLog(urgent?: boolean): Promise<void>;
98
98
  private storeLogToIndexDB;
99
99
  /**
100
100
  * 清理旧日志,只保留最近指定天数的日志
@@ -126,10 +126,11 @@ var LoggerManager = class {
126
126
  logId: (0, import_dayjs.default)().valueOf()
127
127
  };
128
128
  console.log("---- 行为日志", logItem);
129
+ this.logBuffer.push(logItem);
129
130
  if (log.type === "error") {
130
131
  this.sendFeishuNotification({ ...logItem || {}, feishu });
132
+ this.storeLog(true);
131
133
  }
132
- this.logBuffer.push(logItem);
133
134
  }
134
135
  /**
135
136
  * 发送飞书通知
@@ -168,24 +169,24 @@ var LoggerManager = class {
168
169
  }
169
170
  /**
170
171
  * 创建AWS日志文件名
171
- * @param isManual 是否手动上传
172
+ * @param isManual 紧急上传
172
173
  * @returns 日志文件名
173
174
  */
174
- async createAWSFileName(isManual) {
175
+ async createAWSFileName(urgent) {
175
176
  var _a, _b, _c, _d;
176
177
  const _date = (0, import_dayjs.default)().format("YYYY-MM-DD");
177
- const _hour = (0, import_dayjs.default)().format("HH:mm");
178
+ let _hour = (0, import_dayjs.default)().format("HH:mm");
179
+ if (urgent) {
180
+ _hour = `${(0, import_dayjs.default)().format("HH:mm")} [ urgent ] ${(0, import_dayjs.default)().valueOf()}`;
181
+ }
178
182
  if ((_b = (_a = this.app) == null ? void 0 : _a.getPlugin("aws")) == null ? void 0 : _b.createFileName) {
179
183
  return (_d = (_c = this.app) == null ? void 0 : _c.getPlugin("aws")) == null ? void 0 : _d.createFileName({
180
184
  date: _date,
181
185
  hour: _hour,
182
- isManual
186
+ isManual: false
183
187
  });
184
188
  }
185
189
  let fileName = `logs/${"pisell"}/${_date}/${_hour}`;
186
- if (isManual) {
187
- fileName += "-manual";
188
- }
189
190
  return `${fileName}.json`;
190
191
  }
191
192
  /**
@@ -208,13 +209,13 @@ var LoggerManager = class {
208
209
  /**
209
210
  * 存储日志到持久化存储
210
211
  */
211
- async storeLog() {
212
+ async storeLog(urgent) {
212
213
  var _a;
213
214
  if (this.logBuffer.length === 0 || !this.db) {
214
215
  return;
215
216
  }
216
217
  try {
217
- const fileName = await this.createAWSFileName();
218
+ const fileName = await this.createAWSFileName(urgent);
218
219
  console.log("-------- 存储日志到AWS 开始", fileName);
219
220
  const buffer = (_a = this.logBuffer) == null ? void 0 : _a.map((item) => {
220
221
  item.metadata = JSON.parse(item.metadata || "{}");
package/package.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "name": "@pisell/core",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
+ "scripts": {
5
+ "build": "father build",
6
+ "dev": "father dev",
7
+ "build:types": "tsc --project tsconfig.types.json",
8
+ "publish:types": "npm run build:types && cd types && cp ../types-package.json package.json && npm publish"
9
+ },
4
10
  "sideEffects": false,
5
11
  "main": "./lib/index.js",
6
12
  "module": "./es/index.js",
@@ -38,11 +44,5 @@
38
44
  ],
39
45
  "publishConfig": {
40
46
  "access": "public"
41
- },
42
- "scripts": {
43
- "build": "father build",
44
- "dev": "father dev",
45
- "build:types": "tsc --project tsconfig.types.json",
46
- "publish:types": "npm run build:types && cd types && cp ../types-package.json package.json && npm publish"
47
47
  }
48
48
  }