Logger Migration Summary
🎯 Overview
Migrated from console.log to MedusaJS logger for better production logging, log levels, and monitoring.
✅ Files Updated
Subscribers
- ✅
/src/subscribers/social-platform-credentials-encryption.ts- All
console.log→logger.info - All
console.error→logger.error
- All
Workflows
- ✅
/src/workflows/socials/extract-hashtags-mentions.ts- Added logger resolution
- Added try/catch with error logging
- Detailed extraction metrics
Workflow Steps (Pending)
- ⏳
/src/workflows/socials/steps/decrypt-credentials.ts- Partially updated - ⏳
/src/workflows/socials/steps/load-post-with-platform.ts - ⏳
/src/workflows/socials/steps/merge-publish-results.ts - ⏳
/src/workflows/socials/steps/validate-content-compatibility.ts - ⏳
/src/workflows/socials/steps/extract-target-accounts.ts - ⏳
/src/workflows/socials/steps/extract-content.ts - ⏳
/src/workflows/socials/steps/detect-smart-retry.ts - ⏳
/src/workflows/socials/steps/route-to-platform-workflow.ts - ⏳
/src/workflows/socials/steps/update-post-with-results.ts - ⏳
/src/workflows/socials/steps/validate-platform.ts - ⏳
/src/workflows/socials/steps/determine-content-type.ts - ⏳
/src/workflows/socials/steps/encrypt-platform-tokens.ts(can be deleted)
📝 Logger Pattern
Standard Pattern
export const myStep = createStep(
"step-name",
async (input, { container }) => {
const logger = container.resolve("logger")
logger.info("[Step Name] Starting...")
try {
// Step logic
logger.info("[Step Name] ✓ Success message")
return new StepResponse(result)
} catch (error) {
logger.error("[Step Name] ❌ Error:", error)
throw error
}
}
)
Log Levels
logger.info()- Normal operation, success messageslogger.warn()- Warnings, deprecated featureslogger.error()- Errors, failureslogger.debug()- Detailed debugging (use sparingly)
🎯 Benefits
- Structured Logging - Proper log levels for filtering
- Production Ready - Integrates with log aggregation tools
- Better Monitoring - Can track errors and performance
- Consistent Format - All logs follow same pattern
- Environment Aware - Different log levels per environment
🔄 Migration Checklist
Phase 1: Critical Components ✅
- Event subscribers
- Main workflows
- Hashtags/mentions extraction
Phase 2: Workflow Steps (In Progress)
- decrypt-credentials (partial)
- All other workflow steps
Phase 3: Services & Routes
- Social provider services
- API routes
- Webhook handlers
📊 Impact
Before:
console.log("[Step] Message") // No log levels
console.error("Error:", error) // Limited context
After:
logger.info("[Step] Message") // Proper log level
logger.error("[Step] ❌ Error:", error) // Better context
🚀 Next Steps
- Complete workflow steps migration
- Update services and routes
- Configure log levels per environment
- Set up log aggregation (optional)
- Add monitoring dashboards (optional)
Status: In Progress
Last Updated: November 19, 2025
Completed: 3/15 files