File size: 555 Bytes
c8fa89c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import os
import sys

# --- Centralized Debugging Control ---
# To enable, set the environment variable: `export CMP_DEBUG=1`
DEBUG_ENABLED = os.environ.get("CMP_DEBUG", "0") == "1"

def dbg(*args, **kwargs):
    """
    A controlled debug print function. Only prints if DEBUG_ENABLED is True.
    Ensures that debug output does not clutter production runs or HF Spaces logs
    unless explicitly requested. Flushes output to ensure it appears in order.
    """
    if DEBUG_ENABLED:
        print("[DEBUG]", *args, **kwargs, file=sys.stderr, flush=True)