Debug Logging

How to enable and use debug logging for troubleshooting.

WordPress Plugin Logging

The Picture Optimizer plugin includes a built-in process log that captures every step of the processing pipeline.

Viewing the Process Log

During processing, click the View Log button in the modal footer to open a detailed log showing:

  • Timestamps for each operation
  • Upload progress and session creation
  • AI analysis events per image
  • Export progress and file details
  • Replacement results and URL updates
  • Any errors with full error messages

Browser Console

The plugin logs key events to the browser console with the prefix [PO Log]. Open your browser's developer tools (F12 → Console) to see:

[PO Log] Session created: sess_abc123def456
[PO Log] Uploading image 1 of 5...
[PO Log] Analysis complete for img_001
[PO Log] Export complete: 5 images processed

Errors are logged with console.error for easy filtering.

Server-Side Logging

WordPress Debug Log

Enable WordPress debug logging to capture PHP errors:

// In wp-config.php
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Logs are written to wp-content/debug.log. Look for entries from the plugin's PHP classes.

Flask API Gateway Logs

The Flask API gateway logs requests and errors. Check the process manager output:

# If using PM2
pm2 logs image-forge-api

# If using systemd
journalctl -u image-forge-api -f

SaaS Platform Logs

The Next.js SaaS platform logs are available through the process manager:

# If using PM2
pm2 logs picture-optimizer

Common Log Patterns

Successful Processing

[PO Log] Pipeline mode: full
[PO Log] Uploading 3 images...
[PO Log] Session created: sess_xyz
[PO Log] Starting analysis...
[PO Log] Analysis result for img_001: {title: "...", alt: "..."}
[PO Log] Analysis result for img_002: {title: "...", alt: "..."}
[PO Log] Analysis result for img_003: {title: "...", alt: "..."}
[PO Log] Starting export...
[PO Log] Export complete: 3 images
[PO Log] Replacing image 1 of 3...
[PO Log] Replacing image 2 of 3...
[PO Log] Replacing image 3 of 3...
[PO Log] All replacements complete

Credit Error

[PO Log] Pipeline mode: full
[PO Log] Credit check failed: Insufficient credits. You have 2 but need 6.

Network Error

[PO Log] Upload failed: net::ERR_CONNECTION_REFUSED

Reporting Issues

When reporting issues to support, include:

  1. The process log from the modal (copy/paste the full log)
  2. The browser console output (screenshot or copy)
  3. Your WordPress version and PHP version
  4. The plugin version (visible in Plugins → Installed Plugins)
  5. Any server error logs if accessible