feat: 日志优化

This commit is contained in:
zdl
2025-10-18 17:33:15 +08:00
parent a7695c7365
commit 47fcb570c0
10 changed files with 80 additions and 24 deletions

View File

@@ -279,7 +279,11 @@ export default function AuthFormContent() {
// ⚡ Mock 模式:先在前端侧写入 localStorage确保时序正确
if (process.env.REACT_APP_ENABLE_MOCK === 'true' && data.user) {
setCurrentUser(data.user);
console.log('[Auth] 前端侧设置当前用户Mock模式:', data.user);
logger.debug('AuthFormContent', '前端侧设置当前用户(Mock模式)', {
userId: data.user?.id,
phone: data.user?.phone,
mockMode: true
});
}
// 更新session

View File

@@ -1,5 +1,6 @@
import React from "react";
import { FormControl, FormErrorMessage, HStack, Input, Button, Spinner } from "@chakra-ui/react";
import { logger } from "../../utils/logger";
/**
* 通用验证码输入组件
@@ -26,7 +27,12 @@ export default function VerificationCodeInput({
}
} catch (error) {
// 错误已经在父组件处理,这里只需要防止未捕获的 Promise rejection
console.error('Send code error (caught in VerificationCodeInput):', error);
logger.error('VerificationCodeInput', 'handleSendCode', error, {
hasOnSendCode: !!onSendCode,
countdown,
isLoading,
isSending
});
}
};

View File

@@ -4,6 +4,7 @@ import { Typography, Space, Tag } from 'antd';
import { RobotOutlined, FileSearchOutlined } from '@ant-design/icons';
import CitationMark from './CitationMark';
import { processCitationData } from '../../utils/citationUtils';
import { logger } from '../../utils/logger';
const { Text } = Typography;
@@ -37,7 +38,10 @@ const CitedContent = ({
// 如果数据无效,不渲染
if (!processed) {
console.warn('CitedContent: Invalid data, not rendering');
logger.warn('CitedContent', '无效数据,不渲染', {
hasData: !!data,
title
});
return null;
}