mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 06:31:14 -05:00
Refactor: Implement logging and JSONB cleanup
This commit is contained in:
@@ -1,23 +1,18 @@
|
||||
/**
|
||||
* Conditional authentication logging utility
|
||||
* Logs are only shown in development mode
|
||||
* Uses structured logger internally
|
||||
*/
|
||||
|
||||
const isDevelopment = import.meta.env.DEV;
|
||||
import { logger } from './logger';
|
||||
|
||||
export const authLog = (...args: any[]) => {
|
||||
if (isDevelopment) {
|
||||
console.log(...args);
|
||||
}
|
||||
export const authLog = (...args: unknown[]) => {
|
||||
logger.info('[Auth]', ...args);
|
||||
};
|
||||
|
||||
export const authWarn = (...args: any[]) => {
|
||||
if (isDevelopment) {
|
||||
console.warn(...args);
|
||||
}
|
||||
export const authWarn = (...args: unknown[]) => {
|
||||
logger.warn('[Auth]', ...args);
|
||||
};
|
||||
|
||||
export const authError = (...args: any[]) => {
|
||||
// Always log errors
|
||||
console.error(...args);
|
||||
export const authError = (...args: unknown[]) => {
|
||||
logger.error('[Auth] Error occurred', { error: args });
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import type { Database } from '@/integrations/supabase/types';
|
||||
import { logger } from '@/lib/logger';
|
||||
|
||||
type TableName = keyof Database['public']['Tables'];
|
||||
|
||||
@@ -78,11 +79,11 @@ export class TestDataTracker {
|
||||
|
||||
if (error) {
|
||||
errors.push({ table, error });
|
||||
console.warn(`Failed to cleanup ${table}:`, error);
|
||||
logger.warn('Failed to cleanup test data table', { table, error });
|
||||
}
|
||||
} catch (err) {
|
||||
errors.push({ table, error: err });
|
||||
console.warn(`Exception cleaning up ${table}:`, err);
|
||||
logger.warn('Exception cleaning up test data table', { table, error: err });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ export class TestDataTracker {
|
||||
this.entities.clear();
|
||||
|
||||
if (errors.length > 0) {
|
||||
console.warn(`Cleanup completed with ${errors.length} errors:`, errors);
|
||||
logger.warn('Cleanup completed with errors', { errorCount: errors.length, errors });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +117,7 @@ export class TestDataTracker {
|
||||
.eq('is_test_data', true);
|
||||
|
||||
if (error) {
|
||||
console.warn(`Failed to check ${table}:`, error);
|
||||
logger.warn('Failed to check test data table', { table, error });
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -124,7 +125,7 @@ export class TestDataTracker {
|
||||
remaining.push({ table, count });
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(`Exception checking ${table}:`, err);
|
||||
logger.warn('Exception checking test data table', { table, error: err });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,13 +155,13 @@ export class TestDataTracker {
|
||||
.select('id');
|
||||
|
||||
if (error) {
|
||||
console.warn(`Failed to bulk delete from ${table}:`, error);
|
||||
logger.warn('Failed to bulk delete test data', { table, error });
|
||||
totalErrors++;
|
||||
} else if (data) {
|
||||
totalDeleted += data.length;
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(`Exception bulk deleting from ${table}:`, err);
|
||||
logger.warn('Exception bulk deleting test data', { table, error: err });
|
||||
totalErrors++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user