fix(desktop): console.log 清理 — 替换为结构化 logger
将 desktop/src 中 23 处 console.log 替换为 createLogger() 结构化日志: - 生产构建自动静默 debug/info 级别 - 保留 console.error 用于关键错误可见性 - 新增 dompurify 依赖修复 XSS 防护引入缺失 涉及文件: App.tsx, offlineStore.ts, autonomy-manager.ts, gateway-auth.ts, llm-service.ts, request-helper.ts, security-index.ts, skill-discovery.ts, use-onboarding.ts 等 16 个文件
This commit is contained in:
@@ -7,6 +7,10 @@
|
||||
* @module lib/request-helper
|
||||
*/
|
||||
|
||||
import { createLogger } from './logger';
|
||||
|
||||
const log = createLogger('RequestHelper');
|
||||
|
||||
// === Configuration Types ===
|
||||
|
||||
export interface RequestConfig {
|
||||
@@ -161,8 +165,8 @@ export async function requestWithRetry(
|
||||
// Check if we should retry
|
||||
if (retryOn.includes(response.status) && attempt < retries) {
|
||||
const backoff = calculateBackoff(retryDelay, attempt);
|
||||
console.warn(
|
||||
`[RequestHelper] Request failed (${response.status}), ` +
|
||||
log.warn(
|
||||
`Request failed (${response.status}), ` +
|
||||
`retrying in ${backoff}ms (attempt ${attempt + 1}/${retries})`
|
||||
);
|
||||
await delay(backoff);
|
||||
@@ -184,8 +188,8 @@ export async function requestWithRetry(
|
||||
// Check if we should retry
|
||||
if (error.isRetryable(retryOn) && attempt < retries) {
|
||||
const backoff = calculateBackoff(retryDelay, attempt);
|
||||
console.warn(
|
||||
`[RequestHelper] Request error (${error.status}), ` +
|
||||
log.warn(
|
||||
`Request error (${error.status}), ` +
|
||||
`retrying in ${backoff}ms (attempt ${attempt + 1}/${retries})`
|
||||
);
|
||||
await delay(backoff);
|
||||
@@ -206,8 +210,8 @@ export async function requestWithRetry(
|
||||
// Retry on timeout
|
||||
if (attempt < retries) {
|
||||
const backoff = calculateBackoff(retryDelay, attempt);
|
||||
console.warn(
|
||||
`[RequestHelper] Request timed out, ` +
|
||||
log.warn(
|
||||
`Request timed out, ` +
|
||||
`retrying in ${backoff}ms (attempt ${attempt + 1}/${retries})`
|
||||
);
|
||||
await delay(backoff);
|
||||
@@ -411,7 +415,7 @@ export class RequestManager {
|
||||
cancelAll(): void {
|
||||
this.controllers.forEach((controller, id) => {
|
||||
controller.abort();
|
||||
console.log(`[RequestManager] Cancelled request: ${id}`);
|
||||
log.debug(`Cancelled request: ${id}`);
|
||||
});
|
||||
this.controllers.clear();
|
||||
this.requestConfigs.clear();
|
||||
|
||||
Reference in New Issue
Block a user