You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: replace console statements with centralized logger utility (#1057)
* fix: replace console statements with centralized logger utility
- Create environment-aware logger utility (dev/prod)
- Migrate all 150 console.* statements to logger
- Add Sentry-ready structure for future integration
- Configure logger with category-based filtering
- Document logger usage in frontend CLAUDE.md
- Zero ESLint console warnings remaining
Logger features:
- Debug/info only in development
- Warn/error always logged
- Context support for errors
- Performance timing utilities
- TypeScript fully typed
* style: apply prettier formatting to modified files
* docs: fix duplicate logger declarations and remove obsolete TODO
- Fix CLAUDE.md examples to avoid duplicate const declarations
- Remove TODO comment about Sentry since logger is already Sentry-ready
- Clarify logger usage patterns with proper variable names
* refactor: polish Svelte logging patterns
- Remove redundant import.meta.env.DEV checks (logger handles environment automatically)
- Move template logging to proper functions using snippets
- Add comprehensive component context to all error logs
- Update documentation with Svelte-specific logging best practices
Fixed issues:
- NotificationBell: Improved error context for loadNotifications and markAsRead
- DailySummaryCard: Moved template logging to snippet pattern
- FilterSettingsPage: Simplified environment-aware logging
- Added Svelte logging patterns to frontend CLAUDE.md
* refactor: enhance logging practices and documentation
- Standardized logger usage across components by replacing `getLogger('app')` with specific loggers like `loggers.analytics` and `loggers.auth`.
- Improved error logging context in `DailySummaryCard` for better traceability.
- Updated `CLAUDE.md` to include critical guidelines on PII protection and logging best practices.
- Added security-aware logging patterns to prevent exposure of sensitive data.
These changes aim to streamline logging practices and enhance security measures in the codebase.
* feat: implement URL credential redaction in RTSPUrlInput component
- Added a function to redact credentials from RTSP URLs for safer logging.
- Enhanced error logging in the addUrl function to include redacted URLs, improving security and traceability.
These changes aim to protect sensitive information during logging while maintaining functionality.
* refactor: enhance logging context and improve logger utility
- Updated logger usage in NotificationBell and DailySummaryCard components to include detailed context for warnings, improving traceability of issues.
- Renamed logger instance in CLAUDE.md for clarity.
- Enhanced logger interface to support throttling, preventing excessive log messages and improving performance.
These changes aim to streamline logging practices and provide better insights during debugging.
Copy file name to clipboardExpand all lines: frontend/CLAUDE.md
+192Lines changed: 192 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -197,6 +197,198 @@ function getCsrfToken(): string | null {
197
197
headers.set('X-CSRF-Token', getCsrfToken());
198
198
```
199
199
200
+
## Logging
201
+
202
+
Use the centralized logger utility instead of console statements:
203
+
204
+
```typescript
205
+
import { getLogger, loggers } from '$lib/utils/logger';
206
+
207
+
// Option 1: Create a custom logger for your module
208
+
const customLogger = getLogger('myModule');
209
+
210
+
// Option 2: Use predefined category loggers
211
+
const apiLogger = loggers.api; // For API-related logging
212
+
const authLogger = loggers.auth; // For authentication
213
+
const sseLogger = loggers.sse; // For SSE connections
214
+
const audioLogger = loggers.audio; // For audio components
215
+
const uiLogger = loggers.ui; // For UI components
216
+
const settingsLogger = loggers.settings; // For settings
217
+
218
+
// Most common pattern - choose one logger per file:
219
+
const logger = loggers.ui; // For UI components
220
+
```
221
+
222
+
**Important**: Call `getLogger()` once when the module loads and reuse the returned logger instance throughout the module. This prevents creating multiple logger instances inside functions, reducing unnecessary object allocation and ensuring consistent category scoping.
223
+
224
+
### Logger Methods
225
+
226
+
```typescript
227
+
// Debug information (dev only)
228
+
logger.debug('Component initialized', props);
229
+
230
+
// Informational messages (dev only)
231
+
logger.info('Connection established');
232
+
233
+
// Warnings (always logged)
234
+
logger.warn('Deprecated method used');
235
+
236
+
// Errors with context (always logged)
237
+
logger.error('Failed to save', error, {
238
+
component: 'SettingsPage',
239
+
action: 'save',
240
+
userId: user.id,
241
+
});
242
+
243
+
// Performance timing (development only - no-op in production)
0 commit comments