Refactor: Implement logging phases

This commit is contained in:
gpt-engineer-app[bot]
2025-11-03 17:08:36 +00:00
parent 12de4e2ec1
commit b6179372e6
27 changed files with 72 additions and 45 deletions

View File

@@ -10,6 +10,7 @@ import { useAuth } from '@/hooks/useAuth';
import { MFAChallenge } from '@/components/auth/MFAChallenge';
import { toast } from '@/hooks/use-toast';
import type { UserRole } from '@/hooks/useUserRole';
import { handleError } from '@/lib/errorHandler';
interface AdminUserDeletionDialogProps {
open: boolean;
@@ -131,7 +132,10 @@ export function AdminUserDeletionDialog({
}, 2000);
} catch (err) {
console.error('Error deleting user:', err);
handleError(err, {
action: 'Delete User',
metadata: { targetUserId: targetUser.userId }
});
setError(err instanceof Error ? err.message : 'Failed to delete user');
setStep('final_confirm');
}

View File

@@ -4,6 +4,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import { Search, Edit, MapPin, Loader2, X } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { cn } from '@/lib/utils';
import { logger } from '@/lib/logger';
interface LocationResult {
place_id: number;
@@ -64,7 +65,7 @@ export function HeadquartersLocationInput({
setShowResults(true);
}
} catch (error) {
console.error('Error searching locations:', error);
logger.error('Error searching locations', { error });
} finally {
setIsSearching(false);
}

View File

@@ -17,6 +17,7 @@ import { useSuperuserGuard } from '@/hooks/useSuperuserGuard';
import { IntegrationTestRunner as TestRunner, allTestSuites, type TestResult } from '@/lib/integrationTests';
import { Play, Square, Download, ChevronDown, CheckCircle2, XCircle, Clock, SkipForward } from 'lucide-react';
import { toast } from 'sonner';
import { logger } from '@/lib/logger';
export function IntegrationTestRunner() {
const superuserGuard = useSuperuserGuard();
@@ -67,7 +68,7 @@ export function IntegrationTestRunner() {
toast.success(`All ${summary.passed} tests passed!`);
}
} catch (error) {
console.error('Test run error:', error);
logger.error('Test run error', { error });
toast.error('Test run failed');
} finally {
setIsRunning(false);

View File

@@ -102,7 +102,7 @@ export function LocationSearch({ onLocationSelect, initialLocationId, className
// Check if response is OK and content-type is JSON
if (!response.ok) {
const errorMsg = `Location search failed (${response.status}). Please try again.`;
console.error('OpenStreetMap API error:', response.status);
logger.error('OpenStreetMap API error', { status: response.status });
setSearchError(errorMsg);
setResults([]);
setShowResults(false);
@@ -112,7 +112,7 @@ export function LocationSearch({ onLocationSelect, initialLocationId, className
const contentType = response.headers.get('content-type');
if (!contentType || !contentType.includes('application/json')) {
const errorMsg = 'Invalid response from location service. Please try again.';
console.error('Invalid response format from OpenStreetMap');
logger.error('Invalid response format from OpenStreetMap', { contentType });
setSearchError(errorMsg);
setResults([]);
setShowResults(false);

View File

@@ -7,6 +7,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@
import { AlertTriangle, CheckCircle, RefreshCw, Loader2 } from 'lucide-react';
import { supabase } from '@/integrations/supabase/client';
import { format } from 'date-fns';
import { logger } from '@/lib/logger';
interface DuplicateStats {
date: string | null;
@@ -86,7 +87,7 @@ export function NotificationDebugPanel() {
})));
}
} catch (error) {
console.error('Failed to load notification debug data:', error);
logger.error('Failed to load notification debug data', { error });
} finally {
setIsLoading(false);
}

View File

@@ -8,6 +8,7 @@ import { Loader2, Trash2, CheckCircle, AlertCircle } from 'lucide-react';
import { useToast } from '@/hooks/use-toast';
import { supabase } from '@/integrations/supabase/client';
import { format } from 'date-fns';
import { logger } from '@/lib/logger';
export function VersionCleanupSettings() {
const [retentionDays, setRetentionDays] = useState(90);
@@ -52,7 +53,7 @@ export function VersionCleanupSettings() {
setLastCleanup(cleanupValue);
}
} catch (error) {
console.error('Failed to load settings:', error);
logger.error('Failed to load settings', { error });
toast({
title: 'Error',
description: 'Failed to load cleanup settings',