Add configurable logger with PAYLOAD_MAILING_LOG_LEVEL support

- Created centralized logger utility using Payload's built-in logger system
- Added PAYLOAD_MAILING_LOG_LEVEL environment variable for log level configuration
- Replaced all console.log/error/warn calls with structured logger
- Added debug logging for immediate processing flow to help troubleshoot issues
- Improved logging context with specific prefixes (IMMEDIATE, PROCESSOR, JOB_SCHEDULER, etc.)
- Bumped version to 0.4.10

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-20 18:57:18 +02:00
parent 02a9334bf4
commit 2f46dde532
7 changed files with 104 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
import type { PayloadRequest, Payload } from 'payload'
import { processAllEmails } from '../utils/emailProcessor.js'
import { createContextLogger } from '../utils/logger.js'
/**
* Data passed to the process emails task
@@ -67,7 +68,8 @@ export const scheduleEmailsJob = async (
delay?: number
) => {
if (!payload.jobs) {
console.warn('PayloadCMS jobs not configured - emails will not be processed automatically')
const logger = createContextLogger(payload, 'SCHEDULER')
logger.warn('PayloadCMS jobs not configured - emails will not be processed automatically')
return
}
@@ -79,6 +81,7 @@ export const scheduleEmailsJob = async (
waitUntil: delay ? new Date(Date.now() + delay) : undefined,
} as any)
} catch (error) {
console.error('Failed to schedule email processing job:', error)
const logger = createContextLogger(payload, 'SCHEDULER')
logger.error('Failed to schedule email processing job:', error)
}
}