• Blog
  • Documentation
  • Pricing
  • FAQ
  • Contact
Sign InSign Up

The modern toolkit for Accela developers

© Copyright 2025 Radishapps. All Rights Reserved.

Product
  • Documentation
  • Pricing
  • FAQ
Resources
  • Blog
  • Contact
Legal
  • Terms of Service
  • Privacy Policy
  • Cookie Policy

Debug Smarter: AI-Powered Log Enhancement in Seconds

Jan 10, 2025

Transform your Accela EMSE scripts with intelligent debugging. Learn how to use RadishKit AI log enhancer to inject smart logging statements automatically.

Cover Image for Debug Smarter: AI-Powered Log Enhancement in Seconds

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:

  1. RadishKit CLI installed and configured
  2. Project initialized (accli init)
  3. Linked to an agency (accli link)
  4. Authenticated (accli login)
  5. 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:

=== [PERF] processApplicationSubmitAfter START ===
[DEBUG] Input - capId: PR2025-00123
[DEBUG] Retrieved cap - Type: Building/Residential/Addition
[DEBUG] Conditional check: isResidential = true
[INFO] Applying residential permit logic
[DEBUG] Loop iteration 1/5 - Processing condition A
[DEBUG] Loop iteration 2/5 - Processing condition B
...
[PERF] processApplicationSubmitAfter completed in 245ms

Step 4: Save Enhanced Script (Optional)

If you love the AI-enhanced version, you can save it to your script library:

# The enhanced version is shown in the output
# Copy it to your script file or save via web dashboard

Part 2: Advanced CLI AI Enhancement

Custom AI Prompts

Tell the AI exactly what you want to focus on:

accli test Scripts/Batch/BATCH_BILLING.js \
  --ai \
  --ai-prompt "Focus on database query performance and error handling"

The AI will prioritize logs around:

  • Database query execution
  • Query performance metrics
  • Error catching and reporting

AI Templates

Use predefined templates for common scenarios:

# Performance-focused logging
accli test Scripts/Batch/BATCH_SCRIPT.js --ai --ai-template performance

# Debugging-focused logging
accli test Scripts/Event/WTUA.js --ai --ai-template debug

# Production-safe logging (minimal overhead)
accli test Scripts/Event/ASA.js --ai --ai-template production

Available Templates:

  • debug - Comprehensive debugging logs
  • performance - Performance tracking and metrics
  • production - Minimal, production-safe logging
  • error - Focus on error handling and edge cases

Combine with Parameters

AI enhancement works seamlessly with parameter management:

accli test Scripts/Event/WORKFLOWTASKUPDATEAFTER.js \
  --ai \
  --event WTUA \
  --record "PR2025-00123" \
  --task "Building Review" \
  --status "Approved"

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

  1. Log in to RadishKit dashboard
  2. Select your team account
  3. Click "AI Playground" in the sidebar

Step 2: Create or Load a Script

Option A: Start Fresh

  1. Click "New Script"
  2. Enter script name
  3. Select script type (Event, Batch, Generic)
  4. Write or paste your script code

Option B: Load Existing Script

  1. Click "Load from Library"
  2. Select a script from your saved scripts
  3. 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:

  1. Side-by-side comparison - Original vs. Enhanced
  2. Highlight injected logs - Color-coded new statements
  3. Log summary - Count by type (DEBUG, INFO, PERF, ERROR)
  4. Estimated overhead - Performance impact

Step 5: Test Enhanced Script

Click "Test Script" to execute the AI-enhanced version:

  1. Select agency and environment
  2. Add any required parameters
  3. Click "Run Test"
  4. View real-time logs in the execution panel

Step 6: Save to Library

If you're happy with the results:

  1. Click "Save to Library"
  2. 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.

[DEBUG] - Debugging Information

aa.print("[DEBUG] Variable state - recordId: " + recordId + ", status: " + status);
aa.print("[DEBUG] Conditional branch executed: isCommercial = true");
aa.print("[DEBUG] Loop iteration " + i + "/" + totalRecords);

Purpose: Track program flow and variable values.

[INFO] - Informational Messages

aa.print("[INFO] Processing started for 50 records");
aa.print("[INFO] Business rule applied: Residential fee waiver");
aa.print("[INFO] Operation completed successfully");

Purpose: Document normal execution flow and business logic.

[ERROR] - Error Tracking

try {
  // risky operation
} catch (e) {
  aa.print("[ERROR] Operation failed - " + e.message);
  aa.print("[ERROR] Stack trace: " + e.stack);
}

Purpose: Capture and report errors with context.


Part 5: Best Practices

1. Start with Debug Template in Test

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:

  1. Navigate to "Script Executions"
  2. Find your test execution
  3. Click to view detailed logs
  4. Filter by log type: [PERF], [DEBUG], [INFO], [ERROR]

Performance Analysis

The AI-injected [PERF] logs create automatic performance reports:

Function Performance Summary:
├── processApplication: 245ms
│   ├── validateInput: 12ms
│   ├── fetchRecords: 180ms (bottleneck!)
│   └── applyLogic: 53ms
└── Total execution: 245ms

Log Analytics

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:

  1. Check your internet connection
  2. Verify authentication: accli status
  3. Try again (occasional timeout is normal)
  4. 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

  1. Enhance once, reuse many times - Save enhanced scripts to library
  2. Use templates - Faster than custom prompts
  3. 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

  1. AI Playground → Create/load script
  2. Chat with AI → Request enhancement
  3. Preview → Review side-by-side
  4. Test → Execute enhanced version
  5. 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
  • Progress tracking - Loop iteration counters
  • Validation logging - Fee calculation verification
  • Summary statistics - Success/error counts

Time saved: ~30 minutes of manual logging work!


Next Steps

Now that you're an AI enhancement expert:

  1. Master Parameter Management - Combine with saved parameters
  2. Explore Script Library - Organize enhanced scripts
  3. Team Collaboration - Share AI-enhanced scripts

Conclusion

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!


Ready to debug smarter? Try RadishKit's AI Log Enhancer today and transform your development workflow.