Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging for cron events #19

Open
12 of 20 tasks
johnbillion opened this issue Nov 23, 2017 · 6 comments
Open
12 of 20 tasks

Logging for cron events #19

johnbillion opened this issue Nov 23, 2017 · 6 comments
Milestone

Comments

@johnbillion
Copy link
Owner

@johnbillion johnbillion commented Nov 23, 2017

WP Crontrol should log all cron events for debugging purposes and expose the log somewhere.

This can be achieved by iterating distinct cron hooks in the cron array and adding an action which logs the event. Data to log includes:

  • Hook name
  • Timestamp
  • Parameters
  • Callbacks registered at the time the event ran
  • Whether it was run manually (via Run Now) or via the regular scheduling
  • Time taken to run (via an early action and a late action with timing)
  • Did the event miss its scheduled time? By how much?
  • Catch fatals? Probably needs PHP 7. Re-throw them.
  • PHP errors
  • Queries performed
  • HTTP API calls performed
  • Memory used

Plus:

  • Ability to call do_action( 'crontrol_something' ) to log extra data in the event log
  • Ability to throw an exception to cause an event to "fail", similar to Action Scheduler
  • Limit on the number of logs stored. Either a number or a time frame
  • Should be optional, ie. can be turned off
  • Ability to disable event logging by hook name, maybe a filter or maybe a UI control
  • Cron events by default logged in a post type, post meta, terms
  • Storage should be abstracted so it can be stored elsewhere, eg Stream, Simple History, custom table, system logger

Stretch Goals:

  • Extended support for Action Scheduler, list which jobs were triggered
@johnbillion
Copy link
Owner Author

@johnbillion johnbillion commented Aug 18, 2019

This is in progress in the develop branch. Lots still to do.

Edit: This was pulled out. Needs adding back into the develop branch.

@johnbillion johnbillion added this to the 2.0.0 milestone Nov 5, 2019
@johnbillion
Copy link
Owner Author

@johnbillion johnbillion commented Nov 15, 2019

This is now available in 2.0.0-beta1. I might push the remaining features to 2.1, we'll see.

@danieliser
Copy link

@danieliser danieliser commented Oct 20, 2020

@johnbillion These are listed as built into the 2.0.0-beta, but that got scrubbed to 1.8.0 which has been out for some time. I do not see logging in the current versions. Did this get left out and closed on accident?

@johnbillion
Copy link
Owner Author

@johnbillion johnbillion commented Oct 21, 2020

@danieliser Good point, this got reverted because it needs more work for it to be mature and stable. I didn't want to release a part-baked feature. I'll reopen this issue with more details.

In the meantime you can use the develop branch at this specific commit to get the latest version of the feature before I pulled it out: 3472d67

Notably, the UX for selecting which hooks are logged needs more work, and there is no mechanism for limiting the number of events that are logged. You'll need to manually clear the logs periodically otherwise your database can balloon.

@johnbillion johnbillion reopened this Oct 21, 2020
@danieliser
Copy link

@danieliser danieliser commented Oct 21, 2020

Nice, look forward to seeing it finished.

Will say we found 2 plugins that do logging, this one doesn't have a great UI/UX, but seems to function solidly: https://wordpress.org/plugins/cron-logger/

@ShadowXVII
Copy link

@ShadowXVII ShadowXVII commented Jun 29, 2021

Ooh, would love to see this in Crontrol soon. Was using Cron Logger but it's clunky and not great to use.

Some long running jobs hold up the Cron for longer, so as long as "active" sessions/logs of the Cron remain visible. In Cron Logger they just drop off the page in the history even though it's still running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants