Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,15 @@ export default tseslint.config(
],
},
},
// Scripts internos (CLI tools) e testes E2E: console.* é apropriado
{
files: [
"scripts/**/*.{ts,tsx,js,mjs}",
"e2e/**/*.{ts,tsx}",
"tests/e2e/**/*.{ts,tsx}",
],
rules: {
"no-console": "off",
},
},
);
5 changes: 4 additions & 1 deletion src/components/system/IntegrationMigrationMount.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { useEffect, useRef } from "react";
import { supabase } from "@/integrations/supabase/client";
import { invalidateWhatsAppModeCache } from "@/lib/whatsappAdapter";
import { getLogger } from '@/lib/logger';

const log = getLogger('IntegrationMigration');

/**
* Roda `rpc_migrate_whatsapp_integration` uma vez por sessão.
Expand Down Expand Up @@ -31,7 +34,7 @@ export function IntegrationMigrationMount() {
sessionStorage.setItem(SESSION_KEY, "1");
invalidateWhatsAppModeCache();
if (import.meta.env.DEV) {
console.info("[integration-migration] result:", data);
log.info("result:", data);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct console.warn() calls used instead of logger instance, inconsistent with logger usage pattern

Fix on Vercel

Copy link
Copy Markdown

@vercel vercel Bot May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct console.warn() calls used instead of logger instance, inconsistent with logger usage pattern

Fix on Vercel

}
} catch (e) {
console.warn("[integration-migration] error:", e);
Expand Down
7 changes: 6 additions & 1 deletion src/hooks/useContactsRealtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import { supabase } from '@/integrations/supabase/client';
import { DEFAULT_WHATSAPP_INSTANCE } from '@/lib/constants/whatsappInstances';
import type { RealtimeChannel } from '@supabase/supabase-js';
import type { Contact } from '@/hooks/useContacts';
import { getLogger } from '@/lib/logger';

const log = getLogger('useContactsRealtime');



type ContactPayload = Record<string, unknown>;

Expand Down Expand Up @@ -94,7 +99,7 @@ export function useContactsRealtime({
)
.subscribe((status) => {
if (import.meta.env.DEV) {
console.debug(`[useContactsRealtime] Channel "${channelName}" status: ${status}`);
log.debug(`Channel "${channelName}" status: ${status}`);
}
});

Expand Down
7 changes: 5 additions & 2 deletions src/hooks/useEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import { useCallback, useEffect, useRef, useState, useMemo } from 'react';
import { supabase as _supabase } from '@/integrations/supabase/client';
import { safeClient } from '@/integrations/supabase/safeClient';
import { emailMappers } from '@/utils/emailMappers';
import { getLogger } from '@/lib/logger';

const log = getLogger('useEmail');
import { type EmailMessage } from './gmail/gmailTypes';
import { GMAIL_MOCKS } from './gmail/gmailMocks';
import {
Expand Down Expand Up @@ -80,7 +83,7 @@ export function useEmail() {

if (dbErr) {
if (dbErr.message.includes('disponível') || dbErr.message.includes('not found')) {
console.info('[useEmail] Usando dados mock para contas (schema não disponível)');
log.info('Usando dados mock para contas (schema não disponível)');
setAccounts(GMAIL_MOCKS.accounts);
if (GMAIL_MOCKS.accounts.length > 0 && !activeAccountId) {
setActiveAccountId(GMAIL_MOCKS.accounts[0].id);
Expand Down Expand Up @@ -134,7 +137,7 @@ export function useEmail() {

if (rpcErr) {
if (rpcErr.message.includes('disponível') || rpcErr.message.includes('not found')) {
console.info('[useEmail] Usando threads mock');
log.info('Usando threads mock');
setThreads(GMAIL_MOCKS.threads);
setHasMore(false);
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useThemeAudit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ export const useThemeAudit = () => {
setResult({ oledPass, fontPass, colorPass, violations });

if (violations.length > 0) {
// eslint-disable-next-line no-console
console.group('🔍 Relatório de Auditoria Visual');
violations.forEach(v => console.warn(v));
// eslint-disable-next-line no-console
console.groupEnd();
}
};
Expand Down
10 changes: 5 additions & 5 deletions src/integrations/supabase/safeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const safeClient = {
}
});
} catch (err) {
console.warn('[safeClient] Erro ao sincronizar estado de saúde', err);
_log.warn('Erro ao sincronizar estado de saúde', err);
}
},

Expand All @@ -218,11 +218,11 @@ export const safeClient = {
const maskedDetail = this.maskSensitiveData(detail);

if (level === 'error') {
console.error(prefix, message, maskedDetail || '');
_log.error(`${prefix} ${message}`, maskedDetail || '');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Define the logger before replacing console calls

When safeClient.log is reached (for example, any Supabase error or missing email_* resource path that calls this.log(...)), this now throws ReferenceError: _log is not defined instead of returning the handled SafeResponse/mock fallback. I checked the top-level imports in this file and there is no getLogger import or _log declaration, so all three new _log.* branches are currently unusable.

Useful? React with 👍 / 👎.

} else if (level === 'warn') {
console.warn(prefix, message, maskedDetail || '');
_log.warn(`${prefix} ${message}`, maskedDetail || '');
} else {
console.info(prefix, message, maskedDetail || '');
_log.info(`${prefix} ${message}`, maskedDetail || '');
Comment thread
vercel[bot] marked this conversation as resolved.
Copy link
Copy Markdown

@vercel vercel Bot May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log() method uses console.error and console.warn directly instead of logger instance methods for error and warn levels, while info level uses _log.info

Fix on Vercel

}
},

Expand Down Expand Up @@ -313,7 +313,7 @@ export const safeClient = {
});
} catch (dbErr) {
// Ignorar erros de persistência para não travar a operação principal
console.warn('[safeClient] Falha ao persistir log de saúde', dbErr);
_log.warn('Falha ao persistir log de saúde', dbErr);
}
},

Expand Down
4 changes: 4 additions & 0 deletions src/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ class Logger {
}

debug(message: string, ...args: unknown[]): void {
// eslint-disable-next-line no-console
if (this.shouldLog('debug')) console.debug(this.formatMessage('debug', message), ...args);
this.addToSentryBreadcrumb('debug', message, ...args);
}

info(message: string, ...args: unknown[]): void {
// eslint-disable-next-line no-console
if (this.shouldLog('info')) console.info(this.formatMessage('info', message), ...args);
this.addToSentryBreadcrumb('info', message, ...args);
}
Expand Down Expand Up @@ -118,6 +120,7 @@ export function logPerformance(label: string, fn: () => void): void {
const start = performance.now();
fn();
const end = performance.now();
// eslint-disable-next-line no-console
console.debug(`[PERF] [sid:${sessionId.slice(0, 8)}] ${label}: ${(end - start).toFixed(2)}ms`);
}

Expand All @@ -130,6 +133,7 @@ export async function logAsyncPerformance<T>(label: string, fn: () => Promise<T>
const start = performance.now();
const result = await fn();
const end = performance.now();
// eslint-disable-next-line no-console
console.debug(`[PERF] [sid:${sessionId.slice(0, 8)}] ${label}: ${(end - start).toFixed(2)}ms`);
return result;
}
Loading