Files
MajoorWaldi-ComfyUI-Majoor-…/js/utils/logging.js
T
Ewald 97649c9887 perf/test: audit backlog — lazy viewer imports, structured logging, perf budget + unit tests
- ViewerRuntime.js: convert 6 heavy static imports (abCompare, sideBySide,
  model3d, scopes, genInfo, frameExport) to dynamic lazy imports with
  _prewarmViewerModules(); all 8 call sites updated with optional chaining
- logging.js: add mjrDbg() export (gated by APP_CONFIG.DEBUG_VERBOSE_ERRORS);
  replace labeled console.debug() calls in bootstrap.js, useGridLoader.js,
  entry.js
- ttlCache.vitest.mjs: add 4 LRU edge-case tests (10k flood, re-set order,
  post-expiry pruning)
- grid_perf_budget.vitest.mjs: new CI perf-budget suite — 5 tests at 10k+
  assets (budget 400ms, actual ~40ms)
- backfill_jobs.py: new route module extracted from db_maintenance handler
- test_backfill_jobs.py: 61 direct unit tests covering all public functions
- test_db_corruption_recovery.py: new recovery scenario tests
- auth/fetch test suites: auth_refresh_race, client_auth_token, fetch_utils
- js_dist rebuilt

Tests: 393 JS passed, 1428 Python passed, 2 skipped
2026-04-11 11:56:01 +02:00

44 lines
1.2 KiB
JavaScript

import { APP_CONFIG } from "../app/config.js";
import { comfyToast } from "../app/toast.js";
/**
* Structured debug logger — respects the DEBUG_VERBOSE_ERRORS flag.
* Replaces scattered bare console.debug(label, ...) calls so log output
* can be controlled centrally and is silenced in production by default.
*
* Usage: mjrDbg("[Module]", "message", optionalExtra)
*/
export function mjrDbg(tag, ...args) {
try {
if (APP_CONFIG.DEBUG_VERBOSE_ERRORS) {
console.debug(tag, ...args);
}
} catch {
// never throw from a logging helper
}
}
export function reportError(
err,
context = "Majoor",
{ showToast = false, toastType = "error" } = {},
) {
const message = err?.message || String(err || "Unknown error");
try {
if (APP_CONFIG.DEBUG_VERBOSE_ERRORS) {
console.error(`[Majoor][${context}]`, message, err);
} else {
console.debug(`[Majoor][${context}]`, message);
}
} catch (e) {
console.debug?.(e);
}
if (showToast && APP_CONFIG.DEBUG_VERBOSE_ERRORS) {
try {
comfyToast(`${context}: ${message}`, toastType, 4000);
} catch (e) {
console.debug?.(e);
}
}
}