Remove all debugging and verbose logs for production

- Remove detailed trigger matching debug logs
- Remove verbose config initialization console output
- Clean up all 🚨 console.log debugging statements
- Change overly verbose logs to debug level
- Production-ready clean logging output
- Maintain essential error logging and workflow execution info
This commit is contained in:
2025-09-09 12:46:37 +02:00
parent 59a97e519e
commit 6245a71516
4 changed files with 12 additions and 49 deletions

View File

@@ -990,12 +990,6 @@ export class WorkflowExecutor {
previousDoc: unknown, previousDoc: unknown,
req: PayloadRequest req: PayloadRequest
): Promise<void> { ): Promise<void> {
console.log('🚨 EXECUTOR: executeTriggeredWorkflows called!')
console.log('🚨 EXECUTOR: Collection =', collection)
console.log('🚨 EXECUTOR: Operation =', operation)
console.log('🚨 EXECUTOR: Doc ID =', (doc as any)?.id)
console.log('🚨 EXECUTOR: Has payload?', !!this.payload)
console.log('🚨 EXECUTOR: Has logger?', !!this.logger)
this.logger.info({ this.logger.info({
collection, collection,
@@ -1029,24 +1023,11 @@ export class WorkflowExecutor {
} }
}> }>
this.logger.info({ this.logger.debug({
workflowId: workflow.id, workflowId: workflow.id,
workflowName: workflow.name, workflowName: workflow.name,
triggerCount: triggers?.length || 0, triggerCount: triggers?.length || 0
triggers: triggers?.map(t => ({ }, 'Checking workflow triggers')
type: t.type,
parameters: t.parameters,
collection: t.parameters?.collection,
collectionSlug: t.parameters?.collectionSlug,
operation: t.parameters?.operation,
// Debug matching criteria
typeMatch: t.type === 'collection-trigger',
collectionMatch: (t.parameters?.collection === collection || t.parameters?.collectionSlug === collection),
operationMatch: t.parameters?.operation === operation
})),
targetCollection: collection,
targetOperation: operation
}, 'Checking workflow triggers with detailed matching info')
const matchingTriggers = triggers?.filter(trigger => const matchingTriggers = triggers?.filter(trigger =>
trigger.type === 'collection-trigger' && trigger.type === 'collection-trigger' &&
@@ -1090,18 +1071,13 @@ export class WorkflowExecutor {
// Check trigger condition if present // Check trigger condition if present
if (trigger.condition) { if (trigger.condition) {
this.logger.info({ this.logger.debug({
collection, collection,
operation, operation,
condition: trigger.condition, condition: trigger.condition,
docId: (doc as any)?.id,
docFields: doc ? Object.keys(doc) : [],
previousDocId: (previousDoc as any)?.id,
workflowId: workflow.id, workflowId: workflow.id,
workflowName: workflow.name, workflowName: workflow.name
docStatus: (doc as any)?.status, }, 'Evaluating trigger condition')
previousDocStatus: (previousDoc as any)?.status
}, 'Evaluating trigger condition before execution')
const conditionMet = this.evaluateCondition(trigger.condition, context) const conditionMet = this.evaluateCondition(trigger.condition, context)

View File

@@ -145,7 +145,7 @@ export const workflowsPlugin =
// CRITICAL: Modify existing collection configs BEFORE PayloadCMS processes them // CRITICAL: Modify existing collection configs BEFORE PayloadCMS processes them
// This is the ONLY time we can add hooks that will actually work // This is the ONLY time we can add hooks that will actually work
const logger = getConfigLogger() const logger = getConfigLogger()
logger.info('Attempting to modify collection configs before PayloadCMS initialization...') logger.debug('Modifying collection configs...')
if (config.collections && pluginOptions.collectionTriggers) { if (config.collections && pluginOptions.collectionTriggers) {
for (const [triggerSlug, triggerConfig] of Object.entries(pluginOptions.collectionTriggers)) { for (const [triggerSlug, triggerConfig] of Object.entries(pluginOptions.collectionTriggers)) {
@@ -311,10 +311,8 @@ export const workflowsPlugin =
logger.info(`Plugin configuration: ${Object.keys(pluginOptions.collectionTriggers || {}).length} collection triggers, ${pluginOptions.steps?.length || 0} steps`) logger.info(`Plugin configuration: ${Object.keys(pluginOptions.collectionTriggers || {}).length} collection triggers, ${pluginOptions.steps?.length || 0} steps`)
// Create workflow executor instance // Create workflow executor instance
console.log('🚨 CREATING WORKFLOW EXECUTOR INSTANCE') logger.debug('Creating workflow executor instance')
const executor = new WorkflowExecutor(payload, logger) const executor = new WorkflowExecutor(payload, logger)
console.log('🚨 EXECUTOR CREATED:', typeof executor)
console.log('🚨 EXECUTOR METHODS:', Object.getOwnPropertyNames(Object.getPrototypeOf(executor)))
// Register executor with proper dependency injection // Register executor with proper dependency injection
setWorkflowExecutor(executor, logger) setWorkflowExecutor(executor, logger)

View File

@@ -40,13 +40,6 @@ export function initCollectionHooks<T extends string>(pluginOptions: WorkflowsPl
collection.config.hooks.afterChange.push(async (change) => { collection.config.hooks.afterChange.push(async (change) => {
const operation = change.operation as 'create' | 'update' const operation = change.operation as 'create' | 'update'
// AGGRESSIVE LOGGING - this should ALWAYS appear
console.log('🚨 AUTOMATION PLUGIN HOOK CALLED! 🚨')
console.log('Collection:', change.collection.slug)
console.log('Operation:', operation)
console.log('Doc ID:', change.doc?.id)
console.log('Has executor?', !!executor)
console.log('Executor type:', typeof executor)
logger.info({ logger.info({
slug: change.collection.slug, slug: change.collection.slug,
@@ -55,10 +48,9 @@ export function initCollectionHooks<T extends string>(pluginOptions: WorkflowsPl
previousDocId: change.previousDoc?.id, previousDocId: change.previousDoc?.id,
hasExecutor: !!executor, hasExecutor: !!executor,
executorType: typeof executor executorType: typeof executor
}, 'AUTOMATION PLUGIN: Collection hook triggered') }, 'Collection automation hook triggered')
try { try {
console.log('🚨 About to call executeTriggeredWorkflows')
// Execute workflows for this trigger // Execute workflows for this trigger
await executor.executeTriggeredWorkflows( await executor.executeTriggeredWorkflows(
@@ -69,15 +61,13 @@ export function initCollectionHooks<T extends string>(pluginOptions: WorkflowsPl
change.req change.req
) )
console.log('🚨 executeTriggeredWorkflows completed without error')
logger.info({ logger.info({
slug: change.collection.slug, slug: change.collection.slug,
operation, operation,
docId: change.doc?.id docId: change.doc?.id
}, 'AUTOMATION PLUGIN: executeTriggeredWorkflows completed successfully') }, 'Workflow execution completed successfully')
} catch (error) { } catch (error) {
console.log('🚨 AUTOMATION PLUGIN ERROR:', error)
logger.error({ logger.error({
slug: change.collection.slug, slug: change.collection.slug,

View File

@@ -7,8 +7,7 @@ export function initWebhookEndpoint(config: Config, webhookPrefix = 'webhook'):
const logger = getConfigLogger() const logger = getConfigLogger()
// Ensure the prefix starts with a slash // Ensure the prefix starts with a slash
const normalizedPrefix = webhookPrefix.startsWith('/') ? webhookPrefix : `/${webhookPrefix}` const normalizedPrefix = webhookPrefix.startsWith('/') ? webhookPrefix : `/${webhookPrefix}`
logger.debug(`Adding webhook endpoint to config with prefix: ${normalizedPrefix}`) logger.debug(`Adding webhook endpoint: ${normalizedPrefix}`)
logger.debug('Current config.endpoints length:', config.endpoints?.length || 0)
// Define webhook endpoint // Define webhook endpoint
const webhookEndpoint = { const webhookEndpoint = {
@@ -172,7 +171,7 @@ export function initWebhookEndpoint(config: Config, webhookPrefix = 'webhook'):
// Combine existing endpoints with the webhook endpoint // Combine existing endpoints with the webhook endpoint
config.endpoints = [...(config.endpoints || []), webhookEndpoint] config.endpoints = [...(config.endpoints || []), webhookEndpoint]
logger.debug(`Webhook endpoint added at path: ${webhookEndpoint.path}`) logger.debug(`Webhook endpoint added at path: ${webhookEndpoint.path}`)
logger.debug('New config.endpoints length:', config.endpoints.length) logger.debug('Webhook endpoint added')
} else { } else {
logger.debug(`Webhook endpoint already exists at path: ${webhookEndpoint.path}`) logger.debug(`Webhook endpoint already exists at path: ${webhookEndpoint.path}`)
} }