refactor(logging): implement unified Logger system to replace console calls

- Add Logger utility with tagged output and environment-based control
- Configure Babel to remove console calls in production builds
- Replace all console.* calls across stores, services, and components with Logger
- Enable development-only logging with formatted output and component tags
- Optimize production builds by eliminating all logging code
This commit is contained in:
zimplexing
2025-08-15 22:57:38 +08:00
parent 836285dbd5
commit e57466c8c1
25 changed files with 404 additions and 200 deletions

View File

@@ -2,6 +2,9 @@ import { create } from 'zustand';
import updateService from '../services/updateService';
import AsyncStorage from '@react-native-async-storage/async-storage';
import Toast from 'react-native-toast-message';
import Logger from '@/utils/Logger';
const logger = Logger.withTag('UpdateStore');
interface UpdateState {
// 状态
@@ -151,7 +154,7 @@ export const useUpdateStore = create<UpdateState>((set, get) => ({
// 安装开始后,关闭弹窗
set({ showUpdateModal: false });
} catch (error) {
console.info('安装失败:', error);
logger.error('安装失败:', error);
set({
error: error instanceof Error ? error.message : '安装失败',
});
@@ -200,6 +203,6 @@ export const initUpdateStore = async () => {
skipVersion: skipVersion || null,
});
} catch (error) {
console.info('初始化更新存储失败:', error);
logger.error('初始化更新存储失败:', error);
}
};