| description | argument-hint | |
|---|---|---|
Insert strategic logs to spot the issue |
|
Automatically insert strategic debug logs into the code based on the current context. Logs follow a hierarchical taxonomy for easy filtering.
/debugLogs {PREFIX}
PREFIX(optional): Custom prefix for all log statements. Default:>>>
Examples:
/debug-logs- Uses default>>>prefix/debug-logs DEBUG- UsesDEBUGprefix/debug-logs [MyApp]- Uses[MyApp]prefix
Insert debug logs that:
-
Use hierarchical prefixes for filtering:
- Base prefix:
{PREFIX} - Module/file level:
{PREFIX} [ModuleName] - Class level:
{PREFIX} [ModuleName:ClassName] - Method level:
{PREFIX} [ModuleName:ClassName.methodName] - Sub-operation level:
{PREFIX} [ModuleName:ClassName.methodName:operation]
- Base prefix:
-
Follow these principles:
- Place logs at critical decision points, state changes, and error boundaries
- Include relevant variable values and state information
- Log entry/exit points of important functions with parameters/return values
- Add logs before/after external calls (API, database, file system)
- Capture conditional branch decisions
- Log loop iterations for complex loops (with iteration count)
-
Use consistent formatting:
- Entry:
{PREFIX} [Scope] → methodName(param1=value1, param2=value2) - Exit:
{PREFIX} [Scope] ← methodName returned: value - State:
{PREFIX} [Scope] state: variableName=value - Decision:
{PREFIX} [Scope] condition: expression=true/false, taking branch X - Error:
{PREFIX} [Scope] ⚠ error: description - Event:
{PREFIX} [Scope] event: description
- Entry:
-
Use language-appropriate print statements:
- Python:
print("{PREFIX} [Scope] message") - JavaScript/TypeScript:
console.log("{PREFIX} [Scope] message") - Java:
System.out.println("{PREFIX} [Scope] message") - C/C++:
printf("{PREFIX} [Scope] message\n") - Go:
fmt.Println("{PREFIX} [Scope] message") - Rust:
println!("{PREFIX} [Scope] message") - Ruby:
puts "{PREFIX} [Scope] message" - PHP:
echo "{PREFIX} [Scope] message\n" - Swift:
print("{PREFIX} [Scope] message")
- Python:
- Check if a custom prefix was provided: Look for a prefix argument in the slash command invocation (e.g.,
/debug-logs DEBUG). If provided, use that prefix instead of{PREFIX}for all log statements. - Analyze the current conversation context to identify the code being debugged
- Read the relevant source files
- Determine the appropriate scope hierarchy (module, class, method names)
- Automatically insert print statements at critical code locations using the Edit tool, using the custom prefix if provided
- Focus on these critical areas:
- Function entry/exit points with parameters and return values
- State transitions and variable mutations
- Conditional branches and loop iterations
- Error handling paths
- Async operations and callbacks
- External calls (API, database, file system)
- After inserting logs, provide:
- Summary of files modified and number of logs added
- Filtering commands the user can use to view specific log groups (using the actual prefix that was used):
- Filter by module:
grep "{PREFIX} \[ModuleName" - Filter by class:
grep "{PREFIX} \[ModuleName:ClassName" - Filter by method:
grep "{PREFIX} \[ModuleName:ClassName.methodName"
- Filter by module:
IMPORTANT: Use the Edit tool to insert the actual print/console.log statements directly into the code files. Do not just show what the logs would look like - actually modify the files.