File size: 680 Bytes
ee826ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// src/debug-mode.js
// Shared debug utility for Zelin v5.8 modules
// Enable with ZELIN_DEBUG=1 or ZELIN_DEBUG=true

const DEBUG = process.env.ZELIN_DEBUG === '1' || process.env.ZELIN_DEBUG === 'true';

export function isDebug() { return DEBUG; }

export function debugLog(prefix, ...args) {
  if (!DEBUG) return;
  console.log(`[DEBUG:${prefix}]`, ...args);
}

export function debugTrace(prefix, fnName, args = {}) {
  if (!DEBUG) return;
  console.log(`[TRACE:${prefix}] ${fnName}(${Object.keys(args).join(', ')})`, args);
}

export function debugError(prefix, fnName, error) {
  if (!DEBUG) return;
  console.error(`[ERR:${prefix}] ${fnName}:`, error.message, error.stack);
}