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

View File

@@ -15,6 +15,7 @@ from igny8_core.business.content.models import Content
from igny8_core.business.integration.models import SiteIntegration, SyncEvent
logger = logging.getLogger(__name__)
webhook_logger = logging.getLogger('webhooks')
class NoThrottle(BaseThrottle):
@@ -46,14 +47,22 @@ def wordpress_status_webhook(request):
}
"""
try:
webhook_logger.info("="*80)
webhook_logger.info("📥 WORDPRESS STATUS WEBHOOK RECEIVED")
webhook_logger.info(f" Headers: {dict(request.headers)}")
webhook_logger.info(f" Body: {request.data}")
webhook_logger.info("="*80)
# Validate API key
api_key = request.headers.get('X-IGNY8-API-KEY') or request.headers.get('Authorization', '').replace('Bearer ', '')
if not api_key:
webhook_logger.error(" ❌ Missing API key in request headers")
return error_response(
error='Missing API key',
status_code=http_status.HTTP_401_UNAUTHORIZED,
request=request
)
webhook_logger.info(f" ✅ API key present: ***{api_key[-4:]}")
# Get webhook data
data = request.data
@@ -63,10 +72,16 @@ def wordpress_status_webhook(request):
post_url = data.get('post_url')
site_url = data.get('site_url')
logger.info(f"[wordpress_status_webhook] Received webhook: content_id={content_id}, post_id={post_id}, status={post_status}")
webhook_logger.info(f"STEP 1: Parsing webhook data...")
webhook_logger.info(f" - Content ID: {content_id}")
webhook_logger.info(f" - Post ID: {post_id}")
webhook_logger.info(f" - Post Status: {post_status}")
webhook_logger.info(f" - Post URL: {post_url}")
webhook_logger.info(f" - Site URL: {site_url}")
# Validate required fields
if not content_id or not post_id or not post_status:
webhook_logger.error(" ❌ Missing required fields")
return error_response(
error='Missing required fields: content_id, post_id, post_status',
status_code=http_status.HTTP_400_BAD_REQUEST,