0

I want to debug a function on this file https://github.com/Project60/org.project60.banking/blob/9dc6bdcc486753f70948edfd4ea36df0eb9d2f86/extension/api/v3/BankingTransaction.php

/**
 * Analyses the given bank transactions
 *  used as AJAX call
 *
 * @param  list    list of bank_tx ids to process
 * @param  s_list  list of bank_tx_batch ids to process
 *
 * @return  array api result array
 * @access public
 */
function civicrm_api3_banking_transaction_analyselist($params) {
CRM_Core_Error::debug_var ('params', $params);

}

The above function is invoked by button which has onclick event https://github.com/Project60/org.project60.banking/blob/9dc6bdcc486753f70948edfd4ea36df0eb9d2f86/extension/templates/CRM/Banking/Page/Review.tpl

The code is as follows

  <a id="analyseButton" onClick="analysePayment()" class="button"><span title="{ts}Analyse (again){/ts}"><div class="icon preview-icon ui-icon-refresh"></div>{ts}Analyse (again){/ts}</span></a>

But I dont see anything on the log files, how can I get the variables I have checked it under sites/defaut/files/civicrm/ConfigandLog/ I dont see any civicrm.log files or any other files ending with .log dont have value of debug which I have entered Also debug settings has been set to Yes

1 Answer 1

1

The sites/default/files/civicrm/ConfigAndLog/ directory should contain your CiviCRM debug log (and some other files), provided that you're using Drupal, that your Drupal multisite directory is "default", and that the webserver is able to write to that directory. If you're not seeing that, you could:

  • Check assumptions of what CRM_Core_Error::debug_var() will do with the input you're handing it (eg, check that if you pass in a string like SNORK instead of an array, you see that same word appear in a logfile). ::debug_var() looks like it does print_r
  • tail -f /path/to/*.log might reveal which logfiles are being printed to when you hit that endpoint.
  • Check the multisite directory is what you think (should be the same as your settings.php and civicrm.settings.php)
  • Check again for typos (I see defaut in your question, but that's probably not it!)
  • Check that the sites/default/files/ directory and its descendant directories are writable to the webserver (typically user www-data, httpd, _www etc)
  • Double check usage of the debug functions - there have been docs inconsistencies which might lead you astray.
  • Check out CiviCRM docs on debugging
  • There are other SE questions on debugging, eg tips on debugging when you can't view page output also applies well to AJAX callbacks etc where you can't/shouldn't modify page output.

CiviCRM has a more modern log interface available in Civi::log()->debug('debug info'); (see How to print variable/debug data from your extension.php? for an answer on that).

If even that doesn't work, you could fall back to "stock" PHP debugging methods like error_log() and file_put_contents() if CiviCRM debugging isn't working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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