refactor(frontend): Replace console.log with logger utility - Sprint 3 Story 1
Replace all console.log/warn/error statements with unified logger utility. Changes: - Replaced console in lib/hooks/use-stories.ts - Replaced console in lib/signalr/SignalRContext.tsx - Replaced console in lib/hooks/useProjectHub.ts - Replaced console in lib/hooks/use-tasks.ts - Replaced console in lib/hooks/useNotificationHub.ts - Replaced console in lib/hooks/use-projects.ts - Replaced console in app/(dashboard)/projects/[id]/kanban/page.tsx Logger respects NODE_ENV (debug disabled in production). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import { useEffect, useState, useCallback, useRef } from 'react';
|
||||
import { SignalRConnectionManager } from '@/lib/signalr/ConnectionManager';
|
||||
import { SIGNALR_CONFIG } from '@/lib/signalr/config';
|
||||
import { useAuthStore } from '@/stores/authStore';
|
||||
import { logger } from '@/lib/utils/logger';
|
||||
|
||||
export interface Notification {
|
||||
message: string;
|
||||
@@ -32,14 +33,14 @@ export function useNotificationHub() {
|
||||
|
||||
// 监听通知事件
|
||||
manager.on('Notification', (notification: Notification) => {
|
||||
console.log('[NotificationHub] Received notification:', notification);
|
||||
logger.debug('[NotificationHub] Received notification:', notification);
|
||||
setNotifications((prev) => [notification, ...prev].slice(0, 50)); // 保留最近 50 条
|
||||
});
|
||||
|
||||
manager.on(
|
||||
'NotificationRead',
|
||||
(data: { NotificationId: string; ReadAt: string }) => {
|
||||
console.log('[NotificationHub] Notification read:', data);
|
||||
logger.debug('[NotificationHub] Notification read:', data);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -58,7 +59,7 @@ export function useNotificationHub() {
|
||||
try {
|
||||
await managerRef.current.invoke('MarkAsRead', notificationId);
|
||||
} catch (error) {
|
||||
console.error(
|
||||
logger.error(
|
||||
'[NotificationHub] Error marking notification as read:',
|
||||
error
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user