refactor: move logger initialization outside of useCliStatus function

- Moved the logger initialization to the top of the file for better readability and to avoid re-initialization on each function call.
- This change enhances the performance and clarity of the code in the useCliStatus hook.
- fix infinite loop calling caused by rerender because of logger
This commit is contained in:
Shirone
2026-01-06 01:53:08 +01:00
parent 5d675561ba
commit d0b3e0d9bb

View File

@@ -7,6 +7,7 @@ interface UseCliStatusOptions {
setCliStatus: (status: any) => void;
setAuthStatus: (status: any) => void;
}
const logger = createLogger('CliStatus');
export function useCliStatus({
cliType,
@@ -15,7 +16,6 @@ export function useCliStatus({
setAuthStatus,
}: UseCliStatusOptions) {
const [isChecking, setIsChecking] = useState(false);
const logger = createLogger('CliStatus');
const checkStatus = useCallback(async () => {
logger.info(`Starting status check for ${cliType}...`);