@razen-core/zenweb
Version:
A minimalist TypeScript framework for building reactive web applications with no virtual DOM
43 lines • 1.5 kB
JavaScript
/**
* ZenWeb Runtime Debugging
* Debug utilities for development
*/
let debugEnabled = false;
export function enableDebug() {
debugEnabled = true;
console.log('[ZenWeb Debug] Debugging enabled');
}
export function disableDebug() {
debugEnabled = false;
}
export function isDebugEnabled() {
return debugEnabled;
}
export function debugLog(category, message, data) {
if (debugEnabled) {
const timestamp = new Date().toISOString().split('T')[1].split('.')[0];
console.log(`[${timestamp}] [DEBUG:${category}] ${message}`, data || '');
}
}
export function debugWarn(category, message, data) {
if (debugEnabled) {
const timestamp = new Date().toISOString().split('T')[1].split('.')[0];
console.warn(`[${timestamp}] [WARN:${category}] ${message}`, data || '');
}
}
export function debugError(category, message, error) {
if (debugEnabled) {
const timestamp = new Date().toISOString().split('T')[1].split('.')[0];
console.error(`[${timestamp}] [ERROR:${category}] ${message}`, error || '');
}
}
// Enable debug mode if URL has ?debug=true or localStorage has debug flag
if (typeof window !== 'undefined') {
const urlParams = new URLSearchParams(window.location.search);
const hasDebugParam = urlParams.get('debug') === 'true';
const hasDebugStorage = localStorage.getItem('zenweb-debug') === 'true';
if (hasDebugParam || hasDebugStorage) {
enableDebug();
}
}
//# sourceMappingURL=debug.js.map