logging system

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-01 00:43:38 +00:00
parent 42bc24f2c0
commit 3f2385d4d9
10 changed files with 2051 additions and 343 deletions

317
LOGGING-REFERENCE.md Normal file
View File

@@ -0,0 +1,317 @@
# IGNY8 Publish/Sync Logging System
## Overview
Comprehensive file-based logging system for tracking all WordPress publish/sync workflows with site-specific stamps.
## Log Format
All logs include site identification stamps in the format: `[site-id-domain]`
Example: `[16-homeg8.com]`
---
## Backend Logs (IGNY8 SaaS Platform)
### Location
```
/data/app/igny8/backend/logs/publish-sync-logs/
```
### Log Files
#### 1. `publish-sync.log`
**Purpose:** Main workflow logging for content publishing
**Contains:**
- Complete publish workflow from start to finish
- Step-by-step progress (STEP 1, STEP 2, etc.)
- Content preparation (categories, tags, images, SEO)
- Success/failure status
- Timing information (duration in milliseconds)
**Format:**
```
[2025-12-01 00:45:23] [INFO] ================================================================================
[2025-12-01 00:45:23] [INFO] [16-homeg8.com] 🎯 PUBLISH WORKFLOW STARTED
[2025-12-01 00:45:23] [INFO] [16-homeg8.com] Content ID: 123
[2025-12-01 00:45:23] [INFO] [16-homeg8.com] STEP 1: Loading content and integration from database...
[2025-12-01 00:45:23] [INFO] [16-homeg8.com] ✅ Content loaded: 'Article Title'
...
[2025-12-01 00:45:25] [INFO] [16-homeg8.com] 🎉 PUBLISH WORKFLOW COMPLETED SUCCESSFULLY
```
#### 2. `wordpress-api.log`
**Purpose:** HTTP API communication with WordPress sites
**Contains:**
- API requests (method, endpoint, headers, payload)
- API responses (status code, body)
- API errors and timeouts
- Request/response timing
**Format:**
```
[2025-12-01 00:45:24] [INFO] [16-homeg8.com] API REQUEST: POST https://homeg8.com/wp-json/igny8/v1/publish
[2025-12-01 00:45:24] [INFO] [16-homeg8.com] Headers: X-IGNY8-API-Key: ***abcd
[2025-12-01 00:45:24] [INFO] [16-homeg8.com] Payload: {...}
[2025-12-01 00:45:25] [INFO] [16-homeg8.com] API RESPONSE: 201
[2025-12-01 00:45:25] [INFO] [16-homeg8.com] Response body: {"success":true...}
```
#### 3. `webhooks.log`
**Purpose:** Webhook events received from WordPress
**Contains:**
- Webhook POST requests from WordPress
- Status updates from WordPress to IGNY8
- Metadata synchronization events
- Authentication verification
**Format:**
```
[2025-12-01 00:45:30] [INFO] [16-homeg8.com] 📥 WORDPRESS STATUS WEBHOOK RECEIVED
[2025-12-01 00:45:30] [INFO] [16-homeg8.com] Content ID: 123
[2025-12-01 00:45:30] [INFO] [16-homeg8.com] Post ID: 456
[2025-12-01 00:45:30] [INFO] [16-homeg8.com] Post Status: publish
```
### Viewing Backend Logs
```bash
# View all publish logs
tail -f /data/app/igny8/backend/logs/publish-sync-logs/publish-sync.log
# View API communication
tail -f /data/app/igny8/backend/logs/publish-sync-logs/wordpress-api.log
# View webhook events
tail -f /data/app/igny8/backend/logs/publish-sync-logs/webhooks.log
# Search for specific site
grep "\[16-homeg8.com\]" /data/app/igny8/backend/logs/publish-sync-logs/publish-sync.log
# Search for errors
grep "\[ERROR\]" /data/app/igny8/backend/logs/publish-sync-logs/*.log
# View last 100 lines of all logs
tail -n 100 /data/app/igny8/backend/logs/publish-sync-logs/*.log
```
---
## WordPress Plugin Logs
### Location
```
/wp-content/plugins/igny8-ai-os/logs/publish-sync-logs/
```
On your server:
```
/home/u276331481/domains/homeg8.com/public_html/wp-content/plugins/igny8-ai-os/logs/publish-sync-logs/
```
### Log Files
#### 1. `publish-sync.log`
**Purpose:** WordPress post creation and synchronization
**Contains:**
- Post creation workflow
- Categories/tags assignment
- Featured image processing
- SEO metadata updates
- Gallery image handling
- Success/failure status
**Format:**
```
[2025-12-01 00:45:25] [INFO] ================================================================================
[2025-12-01 00:45:25] [INFO] [16-homeg8.com] 🎯 CREATE WORDPRESS POST FROM IGNY8
[2025-12-01 00:45:25] [INFO] [16-homeg8.com] Content ID: 123
[2025-12-01 00:45:25] [INFO] [16-homeg8.com] STEP: Processing 3 categories
[2025-12-01 00:45:25] [INFO] [16-homeg8.com] ✅ Assigned 3 categories to post 456
...
[2025-12-01 00:45:26] [INFO] [16-homeg8.com] 🎉 POST CREATION COMPLETED SUCCESSFULLY
```
#### 2. `wordpress-api.log`
**Purpose:** WordPress outgoing API calls to IGNY8
**Contains:**
- API requests from WordPress to IGNY8
- Task updates
- Status synchronization
- API responses
#### 3. `webhooks.log`
**Purpose:** Outgoing webhook calls from WordPress to IGNY8
**Contains:**
- Status webhook sends
- Metadata webhook sends
- Response handling
### Viewing WordPress Logs
```bash
# On the WordPress server
cd /home/u276331481/domains/homeg8.com/public_html/wp-content/plugins/igny8-ai-os/logs/publish-sync-logs/
# View all publish logs
tail -f publish-sync.log
# View API communication
tail -f wordpress-api.log
# View webhook events
tail -f webhooks.log
# Search for specific content ID
grep "Content ID: 123" publish-sync.log
# View last 50 lines
tail -n 50 publish-sync.log
```
---
## Log Retention
### Automatic Rotation
- **Max file size:** 10 MB per log file
- **Backup count:** 10 rotated files kept
- **Total storage:** ~100 MB per log type (10 files × 10 MB)
### Rotated Files
```
publish-sync.log # Current log
publish-sync.log.1 # Previous rotation
publish-sync.log.2 # Older rotation
...
publish-sync.log.10 # Oldest rotation (auto-deleted when new rotation created)
```
---
## Troubleshooting Guide
### 1. Content Not Publishing
**Check:**
```bash
# Backend - Publishing workflow
grep "PUBLISH WORKFLOW" /data/app/igny8/backend/logs/publish-sync-logs/publish-sync.log | tail -20
# Backend - API errors
grep "\[ERROR\]" /data/app/igny8/backend/logs/publish-sync-logs/wordpress-api.log | tail -20
# WordPress - Post creation
tail -50 /wp-content/plugins/igny8-ai-os/logs/publish-sync-logs/publish-sync.log
```
### 2. Missing Categories/Tags
**Check:**
```bash
# WordPress logs - Category processing
grep "Processing.*categories" /wp-content/plugins/igny8-ai-os/logs/publish-sync-logs/publish-sync.log
# WordPress logs - Tag processing
grep "Processing.*tags" /wp-content/plugins/igny8-ai-os/logs/publish-sync-logs/publish-sync.log
```
### 3. Status Not Syncing
**Check:**
```bash
# Backend - Webhook reception
grep "WEBHOOK RECEIVED" /data/app/igny8/backend/logs/publish-sync-logs/webhooks.log | tail -20
# WordPress - Webhook sending
grep "webhook" /wp-content/plugins/igny8-ai-os/logs/publish-sync-logs/webhooks.log | tail -20
```
### 4. API Connection Issues
**Check:**
```bash
# Backend - API requests/responses
grep "API REQUEST\|API RESPONSE\|API ERROR" /data/app/igny8/backend/logs/publish-sync-logs/wordpress-api.log | tail -30
# Look for timeouts
grep "timeout" /data/app/igny8/backend/logs/publish-sync-logs/*.log
```
---
## Common Log Patterns
### Successful Publish
```
[INFO] [16-homeg8.com] 🎯 PUBLISH WORKFLOW STARTED
[INFO] [16-homeg8.com] STEP 1: Loading content...
[INFO] [16-homeg8.com] STEP 2: Checking if already published...
[INFO] [16-homeg8.com] STEP 3: Generating excerpt...
[INFO] [16-homeg8.com] STEP 4: Loading taxonomy mappings...
[INFO] [16-homeg8.com] STEP 5: Extracting keywords...
[INFO] [16-homeg8.com] STEP 6: Loading images...
[INFO] [16-homeg8.com] STEP 7: Building WordPress API payload...
[INFO] [16-homeg8.com] STEP 8: Sending POST request...
[INFO] [16-homeg8.com] ✅ WordPress responded: HTTP 201
[INFO] [16-homeg8.com] STEP 9: Processing WordPress response...
[INFO] [16-homeg8.com] ✅ WordPress post created successfully
[INFO] [16-homeg8.com] 🎉 PUBLISH WORKFLOW COMPLETED SUCCESSFULLY
```
### API Error
```
[ERROR] [16-homeg8.com] ❌ Unexpected status code: 500
[ERROR] [16-homeg8.com] Response: {"code":"internal_server_error"...}
[ERROR] [16-homeg8.com] API ERROR: WordPress API error: HTTP 500
```
### Missing Fields
```
[WARNING] [16-homeg8.com] ⚠️ No categories in content_data
[WARNING] [16-homeg8.com] ⚠️ No featured image in content_data
[WARNING] [16-homeg8.com] ⚠️ No SEO description in content_data
```
---
## Accessing Logs via Debug Page
The frontend Debug Status page will display these logs in real-time (coming next).
**URL:** https://app.igny8.com/settings/debug-status
---
## Log Cleanup
### Manual Cleanup
```bash
# Backend
rm -f /data/app/igny8/backend/logs/publish-sync-logs/*.log*
# WordPress (on your server)
rm -f /home/u276331481/domains/homeg8.com/public_html/wp-content/plugins/igny8-ai-os/logs/publish-sync-logs/*.log*
```
### Keep Recent Logs Only
```bash
# Keep only last 1000 lines
tail -n 1000 /data/app/igny8/backend/logs/publish-sync-logs/publish-sync.log > /tmp/temp.log
mv /tmp/temp.log /data/app/igny8/backend/logs/publish-sync-logs/publish-sync.log
```
---
## Notes
- All timestamps are in server local time
- Site stamps format: `[site-id-domain]`
- Emoji indicators: 🎯 (start), ✅ (success), ❌ (error), ⚠️ (warning), 🎉 (completion)
- Logs are written in real-time during publish workflows
- File rotation happens automatically at 10MB per file