File size: 2,184 Bytes
0997c23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Debug System Documentation

Unified debug and logging system for ComfyUI-SwissArmyKnife.

## ๐Ÿ“„ Documentation Files

- **[DEBUG_MODE_IMPLEMENTATION.md](DEBUG_MODE_IMPLEMENTATION.md)** - Debug mode implementation and usage
- **[UNIFIED_DEBUG_SYSTEM.md](UNIFIED_DEBUG_SYSTEM.md)** - Unified debug system architecture

## ๐ŸŽฏ Quick Reference

### Debug Configuration

Debug mode can be enabled/disabled via:

1. **Server Config**: `/swissarmyknife/config` endpoint
2. **Environment Variable**: `DEBUG_ENABLED=true`
3. **Runtime**: Toggle via API

### Debug Output

When enabled, debug output appears in:

- Browser console (JavaScript widgets)
- Server logs (Python nodes)
- Network tab (API calls)

### Usage

```python
# Python - use debug logging
from utils.debug import debug_log
debug_log("My debug message", variable_name)
```

```javascript
// JavaScript - conditional logging
const debugLog = (...args) => {
    if (DEBUG_ENABLED) {
        console.log('[ComponentName]', ...args);
    }
};
```

## ๐Ÿ”ง Features

### Unified System

- **Consistent Format**: `[ComponentName] Message: data`
- **Conditional Output**: Only logs when debug mode is enabled
- **Performance**: Zero overhead when disabled
- **Granular Control**: Per-component debug levels

### Component Tags

- `[VideoPreview]` - Video preview widget debug
- `[LoRALoader]` - LoRA loading debug
- `[MediaDescribe]` - Gemini API debug
- `[CivitAI]` - CivitAI integration debug
- `[Cache]` - Caching system debug

## ๐Ÿ› Debugging Workflow

1. **Enable Debug Mode**: Set `DEBUG_ENABLED=true` in config
2. **Reproduce Issue**: Run the workflow that causes the problem
3. **Check Logs**: Review browser console and server logs
4. **Identify Component**: Look for component tags in logs
5. **Analyze Data**: Examine logged variables and state
6. **Fix and Test**: Make changes and verify with debug logs
7. **Disable Debug**: Turn off debug mode for production

## ๐Ÿ“š Related Documentation

- [Caching](../caching/) - For cache-related debugging
- [All Nodes](../../nodes/) - For node-specific debugging
- [Features](../../features/) - For feature debugging

---

**Category**: Infrastructure
**Status**: Stable