Many a times for debugging the codes which are running in background it becomes necessary to print data in logs. Follow the below steps for printing data in watchdog

  1. Enable dblog module in admin/modules page (if it is not enabled)
  2. Add the below code in the background function
watchdog("custom_log", "<pre>" . print_r( $my_data, true) . "</pre>");
  1. Go to admin/reports/dblog to view the data you can filter the content in log page with "custom_log".

Hope this helps!