-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Is your feature request related to a problem? Please describe.
When debugging cron execution issues, the current --verbose flag outputs extensive information from both Drush's internal operations (bootstrap phases, command dispatch, etc.) and Drupal's activities. This creates significant noise that makes it difficult to identify the actual Drupal logs related to cron execution, such as which hook_cron implementations ran, what errors occurred, or what operations were performed.
For example, running drush core:cron -v produces output like:
[info] Drush bootstrap phase: bootstrapDrupalRoot()
[info] Change working directory to /var/www/html/web
[info] Initialized Drupal 10.x root directory at /var/www/html/web
[info] Drush bootstrap phase: bootstrapDrupalSite()
[info] Initialized Drupal site example.com at sites/default
[info] Drush bootstrap phase: bootstrapDrupalConfiguration()
[info] Drush bootstrap phase: bootstrapDrupalDatabase()
[info] Successfully connected to the Drupal database.
[info] Drush bootstrap phase: bootstrapDrupalFull()
... (many more Drush-specific log entries)
[info] Starting execution of system_cron()
[info] Execution of system_cron() took 450.94ms
[info] Cron run completed.
The valuable information about what actually happened during cron execution is buried among Drush's internal logging, making it hard to debug cron failures or monitor cron job execution in production environments.
Describe the solution you'd like
Add new options to the core:cron command to display only Drupal watchdog logs generated during cron execution:
--show-drupal-logs: Display Drupal watchdog logs generated during cron execution--log-severity: Filter logs by minimum severity level (0-7, defaults to 6/info)--log-type: Filter logs by type (e.g., 'cron', 'php', 'system')
Usage examples:
# Show all Drupal logs from cron execution
drush core:cron --show-drupal-logs
# Show only warnings and errors
drush core:cron --show-drupal-logs --log-severity=4
# Show only cron-type logs
drush core:cron --show-drupal-logs --log-type=cron
# Combine with other options
drush core:cron --show-drupal-logs --log-severity=3 --log-type=phpExpected output format:
[notice] Drupal logs generated during cron execution:
--------------------------------------------------------------------------------
[2026-02-06 10:15:32] [INFO] [cron] Starting execution of system_cron()
[2026-02-06 10:15:33] [INFO] [cron] Execution of system_cron() took 450.94ms
[2026-02-06 10:15:33] [ERROR] [php] Notice: Undefined variable in mymodule_cron()
[2026-02-06 10:15:34] [INFO] [cron] Cron run completed.
--------------------------------------------------------------------------------
[success] Total logs displayed: 4
This would provide clean, filtered output showing only what happened in Drupal during cron execution, without the noise from Drush's internal operations.
Describe alternatives you've considered
- Use
watchdog:tailin a separate terminal: This requires running two commands simultaneously and doesn't capture the exact logs from a specific cron run - Parse
drush core:cron -voutput: This is fragile and requires complex filtering to remove Drush's own logging - Query the watchdog table manually after cron runs: This requires knowing the exact timing and doesn't integrate with the cron command workflow
- Create a wrapper script: Adds complexity and doesn't provide a native Drush solution
None of these alternatives provide the clean, integrated experience of having cron execution logs readily available.
Additional context
This feature would be particularly useful for:
- Debugging cron failures: Quickly see which hook_cron implementation failed and why
- Production monitoring: Monitor cron execution in CI/CD pipelines or automated deployments
- Performance analysis: See timing information for each cron hook without Drush overhead
- Log aggregation: Feed clean cron logs to monitoring systems without parsing Drush internals
Related issues:
- If verbose output is enabled, log each hook_cron instance (8.x) #4263 - "If verbose output is enabled, log each hook_cron instance (8.x)" - addresses similar debugging needs for Drush 8.x
- drush cron is sometimes missing info log output "Cron run completed" #6021 - "drush cron is sometimes missing info log output" - shows users rely on log output from cron
The implementation would:
- Capture the last watchdog ID before running cron
- Execute cron normally
- Query the watchdog table for new entries since that ID
- Format and display them with appropriate color coding based on severity
- Require the
dblogmodule to be enabled (validated only when flag is used)