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

@@ -3,6 +3,9 @@ import Cookies from "@react-native-cookies/cookies";
import { api } from "@/services/api";
import { useSettingsStore } from "./settingsStore";
import Toast from "react-native-toast-message";
import Logger from "@/utils/Logger";
const logger = Logger.withTag('AuthStore');
interface AuthState {
isLoggedIn: boolean;
@@ -69,7 +72,7 @@ const useAuthStore = create<AuthState>((set) => ({
}
}
} catch (error) {
console.info("Failed to check login status:", error);
logger.error("Failed to check login status:", error);
if (error instanceof Error && error.message === "UNAUTHORIZED") {
set({ isLoggedIn: false, isLoginModalVisible: true });
} else {
@@ -82,7 +85,7 @@ const useAuthStore = create<AuthState>((set) => ({
await Cookies.clearAll();
set({ isLoggedIn: false, isLoginModalVisible: true });
} catch (error) {
console.info("Failed to logout:", error);
logger.error("Failed to logout:", error);
}
},
}));