@anyul/koishi-plugin-rss 5.3.2 → 5.3.10
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/lib/commands/index.js +1 -3
- package/lib/commands/subscription-create.d.ts +2 -0
- package/lib/commands/subscription-create.js +2 -2
- package/lib/commands/subscription-edit.d.ts +2 -0
- package/lib/commands/subscription-edit.js +8 -12
- package/lib/commands/subscription-management.d.ts +2 -0
- package/lib/commands/subscription-management.js +10 -12
- package/lib/commands/utils.d.ts +0 -5
- package/lib/commands/utils.js +0 -16
- package/lib/commands/web-monitor.d.ts +2 -0
- package/lib/commands/web-monitor.js +2 -2
- package/lib/config.js +4 -10
- package/lib/core/feeder-arg.js +3 -38
- package/lib/core/feeder-runtime.js +0 -5
- package/lib/core/feeder.js +53 -12
- package/lib/core/item-processor-runtime.d.ts +4 -2
- package/lib/core/item-processor-runtime.js +4 -12
- package/lib/core/notification-queue-sender.js +0 -5
- package/lib/core/notification-queue-store.d.ts +7 -0
- package/lib/core/notification-queue-store.js +28 -6
- package/lib/core/notification-queue.d.ts +10 -0
- package/lib/core/notification-queue.js +18 -7
- package/lib/core/parser.js +5 -5
- package/lib/core/renderer.js +7 -7
- package/lib/core/search-format.d.ts +1 -1
- package/lib/core/search-format.js +1 -1
- package/lib/core/subscription-store.d.ts +44 -0
- package/lib/core/subscription-store.js +60 -0
- package/lib/core/telegram-video-restore.js +3 -8
- package/lib/index.d.ts +1 -4
- package/lib/index.js +20 -15
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +51 -32
- package/lib/utils/common.d.ts +6 -0
- package/lib/utils/common.js +20 -30
- package/lib/utils/error-handler.d.ts +49 -0
- package/lib/utils/error-handler.js +111 -1
- package/lib/utils/fetcher.js +12 -38
- package/lib/utils/legacy-config.js +9 -3
- package/lib/utils/logger.d.ts +6 -0
- package/lib/utils/logger.js +82 -14
- package/lib/utils/media.js +21 -21
- package/lib/utils/message-cache.d.ts +8 -0
- package/lib/utils/message-cache.js +12 -0
- package/lib/utils/proxy.d.ts +37 -0
- package/lib/utils/proxy.js +60 -0
- package/package.json +16 -3
- package/lib/commands/error-handler.d.ts +0 -53
- package/lib/commands/error-handler.js +0 -120
- package/lib/commands/rss-subscribe.d.ts +0 -11
- package/lib/commands/rss-subscribe.js +0 -323
- package/lib/core/feeder-old.d.ts +0 -15
- package/lib/core/feeder-old.js +0 -403
- package/lib/utils/error-tracker.d.ts +0 -127
- package/lib/utils/error-tracker.js +0 -352
- package/lib/utils/metrics.d.ts +0 -184
- package/lib/utils/metrics.js +0 -401
- package/lib/utils/structured-logger.d.ts +0 -135
- package/lib/utils/structured-logger.js +0 -248
package/lib/utils/metrics.js
DELETED
|
@@ -1,401 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* 性能监控指标系统
|
|
4
|
-
* 收集和报告应用程序性能指标
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.MetricsCollector = exports.Gauge = exports.Counter = exports.Histogram = exports.MetricType = void 0;
|
|
8
|
-
exports.initMetrics = initMetrics;
|
|
9
|
-
exports.getMetricsCollector = getMetricsCollector;
|
|
10
|
-
exports.incCounter = incCounter;
|
|
11
|
-
exports.setGauge = setGauge;
|
|
12
|
-
exports.observeHistogram = observeHistogram;
|
|
13
|
-
exports.recordRssFetch = recordRssFetch;
|
|
14
|
-
exports.recordRssFetchError = recordRssFetchError;
|
|
15
|
-
exports.recordAiSummary = recordAiSummary;
|
|
16
|
-
exports.recordAiSummaryError = recordAiSummaryError;
|
|
17
|
-
exports.recordMessageSend = recordMessageSend;
|
|
18
|
-
exports.updateMemoryUsage = updateMemoryUsage;
|
|
19
|
-
/**
|
|
20
|
-
* 指标类型
|
|
21
|
-
*/
|
|
22
|
-
var MetricType;
|
|
23
|
-
(function (MetricType) {
|
|
24
|
-
MetricType["COUNTER"] = "counter";
|
|
25
|
-
MetricType["GAUGE"] = "gauge";
|
|
26
|
-
MetricType["HISTOGRAM"] = "histogram";
|
|
27
|
-
MetricType["SUMMARY"] = "summary"; // 摘要(统计信息)
|
|
28
|
-
})(MetricType || (exports.MetricType = MetricType = {}));
|
|
29
|
-
/**
|
|
30
|
-
* 直方图指标
|
|
31
|
-
*/
|
|
32
|
-
class Histogram {
|
|
33
|
-
name;
|
|
34
|
-
description;
|
|
35
|
-
buckets;
|
|
36
|
-
data = new Map();
|
|
37
|
-
sum = 0;
|
|
38
|
-
count = 0;
|
|
39
|
-
constructor(name, description, buckets = [10, 50, 100, 500, 1000, 5000, 10000]) {
|
|
40
|
-
this.name = name;
|
|
41
|
-
this.description = description;
|
|
42
|
-
this.buckets = buckets;
|
|
43
|
-
// 初始化桶
|
|
44
|
-
for (const value of buckets) {
|
|
45
|
-
this.data.set(value.toString(), { le: value, count: 0 });
|
|
46
|
-
}
|
|
47
|
-
// 添加 +Inf 桶
|
|
48
|
-
this.data.set('+Inf', { le: Infinity, count: 0 });
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* 观察一个值
|
|
52
|
-
*/
|
|
53
|
-
observe(value, labels) {
|
|
54
|
-
this.sum += value;
|
|
55
|
-
this.count += 1;
|
|
56
|
-
// 更新桶计数
|
|
57
|
-
for (const [key, bucket] of this.data) {
|
|
58
|
-
if (value <= bucket.le) {
|
|
59
|
-
bucket.count += 1;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* 获取统计信息
|
|
65
|
-
*/
|
|
66
|
-
getStats() {
|
|
67
|
-
const buckets = {};
|
|
68
|
-
for (const [key, bucket] of this.data) {
|
|
69
|
-
buckets[key === '+Inf' ? 'Inf' : key] = bucket.count;
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
count: this.count,
|
|
73
|
-
sum: this.sum,
|
|
74
|
-
avg: this.count > 0 ? this.sum / this.count : 0,
|
|
75
|
-
buckets
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* 重置
|
|
80
|
-
*/
|
|
81
|
-
reset() {
|
|
82
|
-
this.sum = 0;
|
|
83
|
-
this.count = 0;
|
|
84
|
-
for (const bucket of this.data.values()) {
|
|
85
|
-
bucket.count = 0;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
exports.Histogram = Histogram;
|
|
90
|
-
/**
|
|
91
|
-
* 计数器指标
|
|
92
|
-
*/
|
|
93
|
-
class Counter {
|
|
94
|
-
name;
|
|
95
|
-
description;
|
|
96
|
-
value = 0;
|
|
97
|
-
constructor(name, description) {
|
|
98
|
-
this.name = name;
|
|
99
|
-
this.description = description;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* 增加计数
|
|
103
|
-
*/
|
|
104
|
-
inc(delta = 1, labels) {
|
|
105
|
-
this.value += delta;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* 获取当前值
|
|
109
|
-
*/
|
|
110
|
-
get() {
|
|
111
|
-
return this.value;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* 重置
|
|
115
|
-
*/
|
|
116
|
-
reset() {
|
|
117
|
-
this.value = 0;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.Counter = Counter;
|
|
121
|
-
/**
|
|
122
|
-
* 仪表盘指标
|
|
123
|
-
*/
|
|
124
|
-
class Gauge {
|
|
125
|
-
name;
|
|
126
|
-
description;
|
|
127
|
-
value = 0;
|
|
128
|
-
constructor(name, description) {
|
|
129
|
-
this.name = name;
|
|
130
|
-
this.description = description;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* 设置值
|
|
134
|
-
*/
|
|
135
|
-
set(value, labels) {
|
|
136
|
-
this.value = value;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* 增加
|
|
140
|
-
*/
|
|
141
|
-
inc(delta = 1, labels) {
|
|
142
|
-
this.value += delta;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* 减少
|
|
146
|
-
*/
|
|
147
|
-
dec(delta = 1, labels) {
|
|
148
|
-
this.value -= delta;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* 获取当前值
|
|
152
|
-
*/
|
|
153
|
-
get() {
|
|
154
|
-
return this.value;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* 重置
|
|
158
|
-
*/
|
|
159
|
-
reset() {
|
|
160
|
-
this.value = 0;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
exports.Gauge = Gauge;
|
|
164
|
-
/**
|
|
165
|
-
* 性能指标收集器
|
|
166
|
-
*/
|
|
167
|
-
class MetricsCollector {
|
|
168
|
-
metrics = new Map();
|
|
169
|
-
/**
|
|
170
|
-
* 创建或获取计数器
|
|
171
|
-
*/
|
|
172
|
-
getCounter(name, description) {
|
|
173
|
-
if (!this.metrics.has(name)) {
|
|
174
|
-
this.metrics.set(name, new Counter(name, description));
|
|
175
|
-
}
|
|
176
|
-
const metric = this.metrics.get(name);
|
|
177
|
-
if (!(metric instanceof Counter)) {
|
|
178
|
-
throw new Error(`Metric ${name} is not a Counter`);
|
|
179
|
-
}
|
|
180
|
-
return metric;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* 创建或获取仪表盘
|
|
184
|
-
*/
|
|
185
|
-
getGauge(name, description) {
|
|
186
|
-
if (!this.metrics.has(name)) {
|
|
187
|
-
this.metrics.set(name, new Gauge(name, description));
|
|
188
|
-
}
|
|
189
|
-
const metric = this.metrics.get(name);
|
|
190
|
-
if (!(metric instanceof Gauge)) {
|
|
191
|
-
throw new Error(`Metric ${name} is not a Gauge`);
|
|
192
|
-
}
|
|
193
|
-
return metric;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* 创建或获取直方图
|
|
197
|
-
*/
|
|
198
|
-
getHistogram(name, description, buckets) {
|
|
199
|
-
if (!this.metrics.has(name)) {
|
|
200
|
-
this.metrics.set(name, new Histogram(name, description, buckets));
|
|
201
|
-
}
|
|
202
|
-
const metric = this.metrics.get(name);
|
|
203
|
-
if (!(metric instanceof Histogram)) {
|
|
204
|
-
throw new Error(`Metric ${name} is not a Histogram`);
|
|
205
|
-
}
|
|
206
|
-
return metric;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* 获取所有指标
|
|
210
|
-
*/
|
|
211
|
-
getAllMetrics() {
|
|
212
|
-
return this.metrics;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* 重置所有指标
|
|
216
|
-
*/
|
|
217
|
-
resetAll() {
|
|
218
|
-
for (const metric of this.metrics.values()) {
|
|
219
|
-
metric.reset();
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* 生成指标报告
|
|
224
|
-
*/
|
|
225
|
-
generateReport() {
|
|
226
|
-
const lines = [];
|
|
227
|
-
lines.push('# Metrics Report');
|
|
228
|
-
lines.push(`# Generated at: ${new Date().toISOString()}`);
|
|
229
|
-
lines.push('');
|
|
230
|
-
for (const [name, metric] of this.metrics) {
|
|
231
|
-
lines.push(`# ${metric.description}`);
|
|
232
|
-
lines.push(`# TYPE ${name} ${metric.constructor.name}`);
|
|
233
|
-
if (metric instanceof Counter) {
|
|
234
|
-
lines.push(`${name} ${metric.get()}`);
|
|
235
|
-
}
|
|
236
|
-
else if (metric instanceof Gauge) {
|
|
237
|
-
lines.push(`${name} ${metric.get()}`);
|
|
238
|
-
}
|
|
239
|
-
else if (metric instanceof Histogram) {
|
|
240
|
-
const stats = metric.getStats();
|
|
241
|
-
lines.push(`${name}_count ${stats.count}`);
|
|
242
|
-
lines.push(`${name}_sum ${stats.sum}`);
|
|
243
|
-
for (const [bucket, count] of Object.entries(stats.buckets)) {
|
|
244
|
-
lines.push(`${name}_bucket{le="${bucket}"} ${count}`);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
lines.push('');
|
|
248
|
-
}
|
|
249
|
-
return lines.join('\n');
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
exports.MetricsCollector = MetricsCollector;
|
|
253
|
-
// 全局指标收集器实例
|
|
254
|
-
let globalMetricsCollector = null;
|
|
255
|
-
/**
|
|
256
|
-
* 初始化全局指标收集器
|
|
257
|
-
*/
|
|
258
|
-
function initMetrics() {
|
|
259
|
-
if (!globalMetricsCollector) {
|
|
260
|
-
globalMetricsCollector = new MetricsCollector();
|
|
261
|
-
// 注册默认指标
|
|
262
|
-
registerDefaultMetrics(globalMetricsCollector);
|
|
263
|
-
}
|
|
264
|
-
return globalMetricsCollector;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* 注册默认指标
|
|
268
|
-
*/
|
|
269
|
-
function registerDefaultMetrics(collector) {
|
|
270
|
-
// RSS 订阅相关
|
|
271
|
-
collector.getCounter('rss_fetch_total', 'RSS fetch total count');
|
|
272
|
-
collector.getCounter('rss_fetch_success', 'RSS fetch success count');
|
|
273
|
-
collector.getCounter('rss_fetch_error', 'RSS fetch error count');
|
|
274
|
-
collector.getHistogram('rss_fetch_duration', 'RSS fetch duration (ms)');
|
|
275
|
-
// HTML 监控相关
|
|
276
|
-
collector.getCounter('html_monitor_total', 'HTML monitor total count');
|
|
277
|
-
collector.getCounter('html_monitor_success', 'HTML monitor success count');
|
|
278
|
-
collector.getCounter('html_monitor_error', 'HTML monitor error count');
|
|
279
|
-
collector.getHistogram('html_monitor_duration', 'HTML monitor duration (ms)');
|
|
280
|
-
// AI 相关
|
|
281
|
-
collector.getCounter('ai_summary_total', 'AI summary total count');
|
|
282
|
-
collector.getCounter('ai_summary_success', 'AI summary success count');
|
|
283
|
-
collector.getCounter('ai_summary_error', 'AI summary error count');
|
|
284
|
-
collector.getCounter('ai_cache_hit', 'AI cache hit count');
|
|
285
|
-
collector.getCounter('ai_cache_miss', 'AI cache miss count');
|
|
286
|
-
collector.getHistogram('ai_summary_duration', 'AI summary duration (ms)');
|
|
287
|
-
// 消息推送相关
|
|
288
|
-
collector.getCounter('message_send_total', 'Message send total count');
|
|
289
|
-
collector.getCounter('message_send_success', 'Message send success count');
|
|
290
|
-
collector.getCounter('message_send_error', 'Message send error count');
|
|
291
|
-
// 性能相关
|
|
292
|
-
collector.getGauge('memory_usage', 'Memory usage (MB)');
|
|
293
|
-
collector.getGauge('active_subscriptions', 'Active subscriptions count');
|
|
294
|
-
collector.getGauge('queue_size', 'Queue size');
|
|
295
|
-
// Puppeteer 相关
|
|
296
|
-
collector.getCounter('puppeteer_render_total', 'Puppeteer render total count');
|
|
297
|
-
collector.getCounter('puppeteer_render_success', 'Puppeteer render success count');
|
|
298
|
-
collector.getCounter('puppeteer_render_error', 'Puppeteer render error count');
|
|
299
|
-
collector.getHistogram('puppeteer_render_duration', 'Puppeteer render duration (ms)');
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* 获取全局指标收集器
|
|
303
|
-
*/
|
|
304
|
-
function getMetricsCollector() {
|
|
305
|
-
return globalMetricsCollector;
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* 便捷函数:增加计数器
|
|
309
|
-
*/
|
|
310
|
-
function incCounter(name, delta = 1) {
|
|
311
|
-
if (globalMetricsCollector) {
|
|
312
|
-
try {
|
|
313
|
-
globalMetricsCollector.getCounter(name, '').inc(delta);
|
|
314
|
-
}
|
|
315
|
-
catch {
|
|
316
|
-
// 指标不存在,忽略
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* 便捷函数:设置仪表盘
|
|
322
|
-
*/
|
|
323
|
-
function setGauge(name, value) {
|
|
324
|
-
if (globalMetricsCollector) {
|
|
325
|
-
try {
|
|
326
|
-
globalMetricsCollector.getGauge(name, '').set(value);
|
|
327
|
-
}
|
|
328
|
-
catch {
|
|
329
|
-
// 指标不存在,忽略
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* 便捷函数:观察直方图
|
|
335
|
-
*/
|
|
336
|
-
function observeHistogram(name, value) {
|
|
337
|
-
if (globalMetricsCollector) {
|
|
338
|
-
try {
|
|
339
|
-
globalMetricsCollector.getHistogram(name, '').observe(value);
|
|
340
|
-
}
|
|
341
|
-
catch {
|
|
342
|
-
// 指标不存在,忽略
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* 便捷函数:记录 RSS 获取成功
|
|
348
|
-
*/
|
|
349
|
-
function recordRssFetch(duration) {
|
|
350
|
-
incCounter('rss_fetch_total');
|
|
351
|
-
incCounter('rss_fetch_success');
|
|
352
|
-
observeHistogram('rss_fetch_duration', duration);
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* 便捷函数:记录 RSS 获取失败
|
|
356
|
-
*/
|
|
357
|
-
function recordRssFetchError() {
|
|
358
|
-
incCounter('rss_fetch_total');
|
|
359
|
-
incCounter('rss_fetch_error');
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* 便捷函数:记录 AI 摘要成功
|
|
363
|
-
*/
|
|
364
|
-
function recordAiSummary(duration, cached) {
|
|
365
|
-
incCounter('ai_summary_total');
|
|
366
|
-
incCounter('ai_summary_success');
|
|
367
|
-
observeHistogram('ai_summary_duration', duration);
|
|
368
|
-
if (cached) {
|
|
369
|
-
incCounter('ai_cache_hit');
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
incCounter('ai_cache_miss');
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* 便捷函数:记录 AI 摘要失败
|
|
377
|
-
*/
|
|
378
|
-
function recordAiSummaryError() {
|
|
379
|
-
incCounter('ai_summary_total');
|
|
380
|
-
incCounter('ai_summary_error');
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* 便捷函数:记录消息发送
|
|
384
|
-
*/
|
|
385
|
-
function recordMessageSend(success) {
|
|
386
|
-
incCounter('message_send_total');
|
|
387
|
-
if (success) {
|
|
388
|
-
incCounter('message_send_success');
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
incCounter('message_send_error');
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* 更新内存使用指标
|
|
396
|
-
*/
|
|
397
|
-
function updateMemoryUsage() {
|
|
398
|
-
const memoryUsage = process.memoryUsage();
|
|
399
|
-
const heapUsedMB = memoryUsage.heapUsed / 1024 / 1024;
|
|
400
|
-
setGauge('memory_usage', heapUsedMB);
|
|
401
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 观测辅助日志包装层。
|
|
3
|
-
*
|
|
4
|
-
* 注意:当前插件主流程日志入口是 `src/utils/logger.ts` 中的
|
|
5
|
-
* `debug / debugInfo / debugError / createDebugWithContext`。
|
|
6
|
-
* 这里保留为可选的观测与兼容包装,不应作为新业务代码的首选入口。
|
|
7
|
-
*/
|
|
8
|
-
import { Config } from '../types';
|
|
9
|
-
/**
|
|
10
|
-
* 日志级别枚举
|
|
11
|
-
*/
|
|
12
|
-
export declare enum LogLevel {
|
|
13
|
-
DISABLE = "disable",
|
|
14
|
-
ERROR = "error",
|
|
15
|
-
INFO = "info",
|
|
16
|
-
DETAILS = "details"
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* 日志条目接口
|
|
20
|
-
*/
|
|
21
|
-
export interface LogEntry {
|
|
22
|
-
timestamp: string;
|
|
23
|
-
level: LogLevel;
|
|
24
|
-
module: string;
|
|
25
|
-
message: string;
|
|
26
|
-
data?: Record<string, any>;
|
|
27
|
-
error?: {
|
|
28
|
-
name: string;
|
|
29
|
-
message: string;
|
|
30
|
-
stack?: string;
|
|
31
|
-
};
|
|
32
|
-
performance?: {
|
|
33
|
-
duration?: number;
|
|
34
|
-
memory?: number;
|
|
35
|
-
};
|
|
36
|
-
context?: {
|
|
37
|
-
platform?: string;
|
|
38
|
-
guildId?: string;
|
|
39
|
-
userId?: string;
|
|
40
|
-
rssId?: string;
|
|
41
|
-
url?: string;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* 性能计时器
|
|
46
|
-
*/
|
|
47
|
-
export declare class PerformanceTimer {
|
|
48
|
-
private startTime;
|
|
49
|
-
private startMemory;
|
|
50
|
-
constructor();
|
|
51
|
-
/**
|
|
52
|
-
* 获取耗时(毫秒)
|
|
53
|
-
*/
|
|
54
|
-
getDuration(): number;
|
|
55
|
-
/**
|
|
56
|
-
* 获取内存使用(MB)
|
|
57
|
-
*/
|
|
58
|
-
getMemoryUsage(): number;
|
|
59
|
-
/**
|
|
60
|
-
* 获取性能数据
|
|
61
|
-
*/
|
|
62
|
-
getMetrics(): {
|
|
63
|
-
duration: number;
|
|
64
|
-
memory: number;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* 结构化日志记录器类。
|
|
69
|
-
* 内部仍然回落到主日志入口,避免形成第二条日志主线。
|
|
70
|
-
*/
|
|
71
|
-
export declare class StructuredLogger {
|
|
72
|
-
private config;
|
|
73
|
-
private enableJsonOutput;
|
|
74
|
-
constructor(config: Config, enableJsonOutput?: boolean);
|
|
75
|
-
/**
|
|
76
|
-
* 判断是否应该记录日志
|
|
77
|
-
*/
|
|
78
|
-
private shouldLog;
|
|
79
|
-
/**
|
|
80
|
-
* 格式化日志条目
|
|
81
|
-
*/
|
|
82
|
-
private formatEntry;
|
|
83
|
-
/**
|
|
84
|
-
* 记录日志
|
|
85
|
-
*/
|
|
86
|
-
private log;
|
|
87
|
-
/**
|
|
88
|
-
* 记录普通信息
|
|
89
|
-
*/
|
|
90
|
-
info(message: string, module: string, data?: Record<string, any>, context?: LogEntry['context']): void;
|
|
91
|
-
/**
|
|
92
|
-
* 记录详细信息
|
|
93
|
-
*/
|
|
94
|
-
details(message: string, module: string, data?: Record<string, any>, context?: LogEntry['context']): void;
|
|
95
|
-
/**
|
|
96
|
-
* 记录错误
|
|
97
|
-
*/
|
|
98
|
-
error(message: string, module: string, error?: Error, context?: LogEntry['context']): void;
|
|
99
|
-
/**
|
|
100
|
-
* 记录性能数据
|
|
101
|
-
*/
|
|
102
|
-
performance(message: string, module: string, timer: PerformanceTimer, context?: LogEntry['context']): void;
|
|
103
|
-
/**
|
|
104
|
-
* 创建性能计时器
|
|
105
|
-
*/
|
|
106
|
-
createTimer(): PerformanceTimer;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* 初始化全局结构化日志
|
|
110
|
-
*/
|
|
111
|
-
export declare function initStructuredLogger(config: Config, enableJsonOutput?: boolean): void;
|
|
112
|
-
/**
|
|
113
|
-
* 获取全局结构化日志实例
|
|
114
|
-
*/
|
|
115
|
-
export declare function getStructuredLogger(): StructuredLogger | null;
|
|
116
|
-
/**
|
|
117
|
-
* 便捷方法:记录信息
|
|
118
|
-
*/
|
|
119
|
-
export declare function logInfo(message: string, module: string, data?: Record<string, any>, context?: LogEntry['context']): void;
|
|
120
|
-
/**
|
|
121
|
-
* 便捷方法:记录详细信息
|
|
122
|
-
*/
|
|
123
|
-
export declare function logDetails(message: string, module: string, data?: Record<string, any>, context?: LogEntry['context']): void;
|
|
124
|
-
/**
|
|
125
|
-
* 便捷方法:记录错误
|
|
126
|
-
*/
|
|
127
|
-
export declare function logError(message: string, module: string, error?: Error, context?: LogEntry['context']): void;
|
|
128
|
-
/**
|
|
129
|
-
* 便捷方法:创建计时器
|
|
130
|
-
*/
|
|
131
|
-
export declare function createTimer(): PerformanceTimer;
|
|
132
|
-
/**
|
|
133
|
-
* 便捷方法:记录性能
|
|
134
|
-
*/
|
|
135
|
-
export declare function logPerformance(message: string, module: string, timer: PerformanceTimer, context?: LogEntry['context']): void;
|