Debug Smarter: AI-Powered Log Enhancement in Seconds
Debug Smarter: AI-Powered Log Enhancement in Seconds
Transform your Accela EMSE scripts with intelligent debugging. Learn how to use RadishKit AI log enhancer to inject smart logging statements automatically.
Debug Smarter: AI-Powered Log Enhancement in Seconds
How much time do you spend adding logging statements to your Accela EMSE scripts? Figuring out where to place logs, what to log, and at what level? If you're like most developers, it's more time than you'd like to admit.
RadishKit's AI Log Enhancer changes everything. With a single flag, AI analyzes your script and automatically injects intelligent logging statements at the right places—tracking execution flow, variable values, performance metrics, and potential errors.
In this guide, you'll learn how to leverage this powerful feature to debug faster and with more confidence.
What You'll Learn
How AI log enhancement works
Step-by-step guide to enhancing scripts via CLI
Using the AI Playground in the web dashboard
Advanced AI enhancement techniques
Best practices for production debugging
Why AI-Enhanced Logging?
The Traditional Approach
Manual logging in EMSE scripts typically looks like this:
// Manual logging - tedious and inconsistent
function processApplication(capId) {
aa.print("Starting processApplication");
var cap = aa.cap.getCap(capId).getOutput();
aa.print("Retrieved cap: " + capId);
// ... lots of code ...
var result = doSomething();
aa.print("Result: " + result);
return result;
}
Problems:
❌ Time-consuming to write
❌ Inconsistent formatting
❌ Missing critical information
❌ No performance tracking
❌ Clutters your code
The AI-Enhanced Approach
With RadishKit's AI log enhancer:
// AI-enhanced logging - comprehensive and intelligent
function processApplication(capId) {
aa.print("=== [PERF] processApplication START ===");
aa.print("[DEBUG] Input parameter - capId: " + capId);
var startTime = new Date().getTime();
var cap = aa.cap.getCap(capId).getOutput();
aa.print("[DEBUG] Retrieved cap object - Type: " + cap.getCapType());
aa.print("[DEBUG] Cap status: " + cap.getCapStatus());
// ... lots of code with smart logging throughout ...
var result = doSomething();
aa.print("[INFO] Processing completed - Result: " + result);
var endTime = new Date().getTime();
aa.print("[PERF] processApplication completed in " + (endTime - startTime) + "ms");
return result;
}
Benefits:
✅ Generated in seconds
✅ Consistent, professional formatting
✅ Tracks performance automatically
✅ Logs key variables and state
✅ Includes execution flow markers
Prerequisites
Before we begin, ensure you have:
RadishKit CLI installed and configured
Project initialized (accli init)
Linked to an agency (accli link)
Authenticated (accli login)
An EMSE script to enhance
Part 1: CLI AI Enhancement (Quick Start)
The fastest way to enhance a script is directly from your terminal using the CLI.
Step 1: Basic AI Enhancement
Simply add the --ai flag to your test command:
accli test Scripts/Event/APPLICATIONSUBMITAFTER.js --ai
Step 2: Watch the Magic Happen
RadishKit sends your script to the AI service for analysis. You'll see:
🤖 AI Script Analyzer: Processing script...
Analyzing script structure...
Identifying key execution paths...
Determining optimal log placement...
✅ AI Analysis Complete
📊 Logs injected: 8
🔄 Processing time: 1.2s
📈 Enhanced script size: 2.4KB (original: 1.5KB)
📋 Injected Logs:
1. [PERF] Track function entry and start time
2. [DEBUG] Log input parameters
3. [DEBUG] Track conditional branch execution
4. [DEBUG] Log API call results
5. [INFO] Log business logic decisions
6. [ERROR] Catch and log exceptions
7. [DEBUG] Log loop iterations
8. [PERF] Track function completion and duration
🚀 Executing enhanced script...
Step 3: Review Results
The enhanced script executes immediately, and you can see the AI-injected logs in the output:
The AI-enhanced script executes with your saved parameters!
Part 3: Web Dashboard AI Playground
For a more visual experience, use the AI Playground in the RadishKit web dashboard.
Step 1: Navigate to AI Playground
Log in to RadishKit dashboard
Select your team account
Click "AI Playground" in the sidebar
Step 2: Create or Load a Script
Option A: Start Fresh
Click "New Script"
Enter script name
Select script type (Event, Batch, Generic)
Write or paste your script code
Option B: Load Existing Script
Click "Load from Library"
Select a script from your saved scripts
Edit as needed
Step 3: Chat with AI Assistant
The AI Playground includes an interactive chat:
You: "Enhance this script with comprehensive logging"
AI: "I'll analyze your script and add intelligent logging
statements. I'll focus on:
- Function entry/exit points
- Variable state tracking
- Performance metrics
- Error handling
Would you like me to proceed?"
You: "Yes, also add extra logging around the database queries"
AI: "Perfect! I'll pay special attention to database operations,
including query timing and result validation. Generating
enhanced script now..."
Step 4: Preview AI Enhancements
The AI generates the enhanced script and shows:
Side-by-side comparison - Original vs. Enhanced
Highlight injected logs - Color-coded new statements
Log summary - Count by type (DEBUG, INFO, PERF, ERROR)
Estimated overhead - Performance impact
Step 5: Test Enhanced Script
Click "Test Script" to execute the AI-enhanced version:
Select agency and environment
Add any required parameters
Click "Run Test"
View real-time logs in the execution panel
Step 6: Save to Library
If you're happy with the results:
Click "Save to Library"
Choose to save as:
New version - Creates a new version of existing script
New script - Saves as separate script with "-enhanced" suffix
Replace original - Overwrites the original (use with caution!)
Part 4: Understanding AI Log Types
The AI uses structured log types for clarity:
[PERF] - Performance Tracking
aa.print("=== [PERF] functionName START ===");
var startTime = new Date().getTime();
// ... code ...
var duration = new Date().getTime() - startTime;
aa.print("[PERF] functionName completed in " + duration + "ms");
Purpose: Track execution time and identify bottlenecks.
For initial development, use comprehensive logging:
accli test Scripts/Event/NEW_SCRIPT.js --ai --ai-template debug
2. Switch to Production Template for Deployment
Before deploying, use production-safe logging:
accli test Scripts/Event/NEW_SCRIPT.js --ai --ai-template production
3. Use Custom Prompts for Specific Issues
When debugging a specific problem:
accli test Scripts/Batch/PROBLEM_SCRIPT.js \
--ai \
--ai-prompt "Focus on the invoice calculation loop and array boundary checks"
4. Review Before Committing
Always test AI-enhanced scripts in rollback mode first:
# Test safely
accli test Scripts/Event/ENHANCED.js --ai
# Review logs in web dashboard
# When satisfied, commit
accli run Scripts/Event/ENHANCED.js --ai
5. Save AI Configurations
For scripts you enhance regularly, document your AI prompts:
# Create a notes file
echo "AI Prompt: Focus on fee calculation and payment processing" > \
Scripts/.ai-prompts/BILLING_SCRIPT.txt
Part 6: Advanced Techniques
Iterative Enhancement
Refine AI logging through conversation in the AI Playground:
You: "Enhance this script with logging"
[AI generates enhanced script]
You: "Remove the debug logs from the helper functions,
but keep the performance tracking"
[AI refines the script]
You: "Add error handling around the external API calls"
[AI adds try-catch blocks with error logging]
Selective Enhancement
Enhance only specific functions:
accli test Scripts/Helper/UTILS.js \
--ai \
--ai-prompt "Only add logging to the calculateFees and validatePayment functions"
Multi-Script Enhancement
Enhance multiple related scripts consistently:
# Enhance all event scripts with same template
for script in Scripts/Event/*.js; do
accli test "$script" --ai --ai-template production
done
Part 7: Monitoring AI-Enhanced Execution
Real-Time Logs
View AI-injected logs in real-time in the web dashboard:
Navigate to "Script Executions"
Find your test execution
Click to view detailed logs
Filter by log type: [PERF], [DEBUG], [INFO], [ERROR]
Performance Analysis
The AI-injected [PERF] logs create automatic performance reports:
RadishKit tracks patterns in your AI-enhanced logs:
Most common execution paths
Average performance by function
Error frequencies and patterns
Execution trends over time
Troubleshooting
AI Enhancement Fails
Issue: Error message "AI service unavailable"
Solution:
Check your internet connection
Verify authentication: accli status
Try again (occasional timeout is normal)
Check RadishKit status page
Too Many Logs Generated
Issue: AI adds too many log statements
Solution: Use a custom prompt to reduce logging:
accli test script.js \
--ai \
--ai-prompt "Add only essential performance and error logs, minimal debugging"
AI Misunderstands Script Logic
Issue: Logs don't capture the right information
Solution: Be specific in your prompt:
accli test script.js \
--ai \
--ai-prompt "This script processes invoices in batches of 100.
Focus logging on batch boundaries and payment processing"
Enhanced Script Performs Poorly
Issue: Too much logging overhead
Solution: Use the production template:
accli test script.js --ai --ai-template production
Cost Considerations
AI Enhancement Pricing
Free tier: 50 AI enhancements per month
Pro tier: 500 AI enhancements per month
Enterprise tier: Unlimited AI enhancements
Each enhancement counts as one use, regardless of script size.
Optimization Tips
Enhance once, reuse many times - Save enhanced scripts to library
Use templates - Faster than custom prompts
Enhance critical scripts - Reserve AI for complex scripts
Quick Reference
CLI Commands
# Basic enhancement
accli test script.js --ai
# With custom prompt
accli test script.js --ai --ai-prompt "YOUR PROMPT"
# With template
accli test script.js --ai --ai-template debug
# Combine with parameters
accli test script.js --ai --event WTUA --record "RECORD_ID"
# Enhance and commit
accli run script.js --ai
Web Dashboard
AI Playground → Create/load script
Chat with AI → Request enhancement
Preview → Review side-by-side
Test → Execute enhanced version
Save → Add to script library
Real-World Example
Let's walk through enhancing a real billing batch script:
Original Script (50 lines, no logging)
function processBillingBatch() {
var records = getUnbilledRecords();
for (var i = 0; i < records.length; i++) {
var record = records[i];
var fee = calculateFee(record);
var invoice = createInvoice(record, fee);
submitInvoice(invoice);
}
}
CLI Enhancement
accli test Scripts/Batch/BILLING_BATCH.js \
--ai \
--ai-prompt "Focus on loop performance, fee calculation accuracy, and error handling"
AI-Enhanced Script (82 lines with intelligent logging)
function processBillingBatch() {
aa.print("=== [PERF] processBillingBatch START ===");
var batchStartTime = new Date().getTime();
aa.print("[INFO] Fetching unbilled records");
var records = getUnbilledRecords();
aa.print("[INFO] Found " + records.length + " unbilled records");
var successCount = 0;
var errorCount = 0;
for (var i = 0; i < records.length; i++) {
var loopStartTime = new Date().getTime();
var record = records[i];
aa.print("[DEBUG] Processing record " + (i+1) + "/" + records.length +
" - ID: " + record.id);
try {
var fee = calculateFee(record);
aa.print("[DEBUG] Calculated fee: $" + fee + " for record " + record.id);
if (fee <= 0) {
aa.print("[ERROR] Invalid fee calculated: $" + fee);
errorCount++;
continue;
}
var invoice = createInvoice(record, fee);
aa.print("[DEBUG] Invoice created - Number: " + invoice.number);
submitInvoice(invoice);
successCount++;
var loopDuration = new Date().getTime() - loopStartTime;
aa.print("[PERF] Record processed in " + loopDuration + "ms");
} catch (e) {
aa.print("[ERROR] Failed to process record " + record.id +
" - " + e.message);
errorCount++;
}
}
var batchDuration = new Date().getTime() - batchStartTime;
aa.print("[INFO] Batch complete - Success: " + successCount +
", Errors: " + errorCount);
aa.print("[PERF] processBillingBatch completed in " + batchDuration + "ms");
aa.print("[PERF] Average per record: " +
(batchDuration / records.length) + "ms");
}
Results
8 performance logs - Track batch and per-record timing
Error handling - Try-catch with detailed error logging
RadishKit's AI Log Enhancer transforms hours of tedious logging work into seconds of intelligent automation. By leveraging AI to understand your script's logic and inject comprehensive, structured logging, you can:
Debug faster with better visibility
Identify bottlenecks with automatic performance tracking
Catch errors with comprehensive error logging
Save time - 30-60 minutes per script
Maintain consistency across all your scripts
Stop manually writing aa.print() statements and let AI do the heavy lifting. Your debugging workflow will never be the same!