-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.js
More file actions
92 lines (80 loc) · 2.56 KB
/
Copy pathdebug.js
File metadata and controls
92 lines (80 loc) · 2.56 KB
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
83
84
85
86
87
88
89
90
91
92
// Limn - Unified Debug Logging System
// All logs appear in DevTools console only
const Debug = {
// Enable/disable categories
enabled: {
RAG: true,
Actions: true,
OpenRouter: true,
Chat: true,
Prefs: true,
Main: true,
Companion: true,
UnifiedAgent: true
},
// Color codes for categories (DevTools supports %c styling)
colors: {
RAG: '#27ae60', // Green
Actions: '#e67e22', // Orange
OpenRouter: '#3498db', // Blue
Chat: '#1abc9c', // Teal
Prefs: '#95a5a6', // Gray
Main: '#34495e', // Dark gray
Companion: '#e91e63', // Pink
UnifiedAgent: '#9b59b6' // Purple
},
// Format timestamp
timestamp() {
return new Date().toISOString().substr(11, 12);
},
// Main logging function
log(category, action, data = {}) {
if (!this.enabled[category]) return;
const ts = this.timestamp();
const hasData = Object.keys(data).length > 0;
// Simple flat logging - no groups, data inline
if (hasData) {
console.log(`[${ts}][${category}] ${action}`, data);
} else {
console.log(`[${ts}][${category}] ${action}`);
}
},
// Convenience methods for each category
rag(action, data) { this.log('RAG', action, data); },
unifiedAgent(action, data) { this.log('UnifiedAgent', action, data); },
actions(action, data) { this.log('Actions', action, data); },
openRouter(action, data) { this.log('OpenRouter', action, data); },
chat(action, data) { this.log('Chat', action, data); },
prefs(action, data) { this.log('Prefs', action, data); },
main(action, data) { this.log('Main', action, data); },
companion(action, data) { this.log('Companion', action, data); },
// Error logging (always shown)
error(category, action, error) {
const ts = this.timestamp();
console.error(`[${ts}][${category}] ERROR: ${action}`, {
message: error?.message || error,
stack: error?.stack
});
},
// Toggle category
toggle(category) {
if (this.enabled.hasOwnProperty(category)) {
this.enabled[category] = !this.enabled[category];
console.log(`[Debug] ${category} logging: ${this.enabled[category] ? 'ON' : 'OFF'}`);
}
},
// Enable all
enableAll() {
Object.keys(this.enabled).forEach(k => this.enabled[k] = true);
console.log('[Debug] All categories enabled');
},
// Disable all
disableAll() {
Object.keys(this.enabled).forEach(k => this.enabled[k] = false);
console.log('[Debug] All categories disabled');
}
};
// Export
if (typeof window !== 'undefined') {
window.Debug = Debug;
}