Files
SRCmail/lib/debug.ts
T
Matthieu MALVACHEandMatthieu MALVACHE cf21a84263 Initial release: JMAP Webmail Client
A modern, privacy-focused webmail client built with Next.js and the JMAP protocol.
Designed for Stalwart Mail Server.

Features:
- Full email operations (compose, reply, forward, threading)
- Real-time push notifications
- Dark/light theme support
- Mobile responsive design
- Keyboard shortcuts
- Drag-and-drop organization
- i18n (English/French)
- Security-first (external content blocked, HTML sanitization)
2025-12-10 17:54:22 +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);
}
}
};