Files
jmap-webmail/lib/debug.ts
T
Matthieu MALVACHE 63cb80cb1d feat: Wire up disconnected settings to actual functionality
- showPreview: Conditionally render email preview in list based on setting
- externalContentPolicy: Control external content (ask/block/allow modes)
- deleteAction: Move to trash or permanently delete based on preference
- debugMode: Add conditional logging via new lib/debug.ts utility

Also includes:
- Add moveToTrash method to JMAP client for trash-based deletion
- Update TODO.md with verified implementation status
- Migrate middleware.ts to proxy.ts (Next.js deprecation)
2025-12-09 23:51:20 +01:00

78 lines
1.7 KiB
TypeScript

import { useSettingsStore } from '@/stores/settings-store';
/**
* Debug logger that respects the debugMode setting.
* Use this instead of console.log for conditional debug output.
*/
export const debug = {
/**
* Log a debug message (only when debugMode is enabled)
*/
log: (...args: unknown[]) => {
if (useSettingsStore.getState().debugMode) {
console.log('[DEBUG]', ...args);
}
},
/**
* Log a warning message (only when debugMode is enabled)
*/
warn: (...args: unknown[]) => {
if (useSettingsStore.getState().debugMode) {
console.warn('[DEBUG]', ...args);
}
},
/**
* Log an error message (always logs, regardless of debugMode)
*/
error: (...args: unknown[]) => {
console.error('[ERROR]', ...args);
},
/**
* Start a collapsed console group (only when debugMode is enabled)
*/
group: (label: string) => {
if (useSettingsStore.getState().debugMode) {
console.group(`[DEBUG] ${label}`);
}
},
/**
* End a console group (only when debugMode is enabled)
*/
groupEnd: () => {
if (useSettingsStore.getState().debugMode) {
console.groupEnd();
}
},
/**
* Start a performance timer (only when debugMode is enabled)
*/
time: (label: string) => {
if (useSettingsStore.getState().debugMode) {
console.time(`[DEBUG] ${label}`);
}
},
/**
* End a performance timer (only when debugMode is enabled)
*/
timeEnd: (label: string) => {
if (useSettingsStore.getState().debugMode) {
console.timeEnd(`[DEBUG] ${label}`);
}
},
/**
* Log a table (only when debugMode is enabled)
*/
table: (data: unknown) => {
if (useSettingsStore.getState().debugMode) {
console.table(data);
}
}
};