4

Does anybody know of the proper way to debug objects from within hook_cron? I'm trying to set up a task that periodically deletes backups from my private folder, but I can't properly debug arrays that I define in my module. I've tried both the object log and devel debug log modules, but neither of them are properly working for me at the moment, so I feel completely stuck on how to access the information I need.

I've tried running kint() directly, but I'm assuming that doesn't work because it's not running on a page load but in the middle of the cron task.

EDIT: Ended up solving this particular piece of the issue, but am having errors doing some of the deletion as addressed in another issue.

1

You might want to try a module like Ultimate Cron that allows you to run individual cron jobs, outside of cron.php. This will allow you to use kint() and see the output.

  • Great suggestion! Except that the individual cron job running functionality seems to be broken right now, at least on my end. I wonder if I've got another issue going on, here, that's affecting everything I'm trying... – Mrweiner Jan 31 '17 at 22:54
  • Actually that may have been an alpha vs dev issue, because I switched over to the most recent dev version and the individual runs are working. Still no sign of my kint messages on screen, though. : / – Mrweiner Jan 31 '17 at 23:35
0

I ended up using Ultimate Cron to run my specific cron task on demand, but used a method other than kint() to print my info. I ended up setting my info to a variable $folders and using the following to print the information in a text file: file_put_contents("$private_path/folders.txt", print_r($folders, true))

0

echo are displayed with drush on hook_cron.

A quick but not complete solution could be to echo flat array using this way. It could do the trick depending of your need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.