Using debug with services 3 (drupal 7)
Pergunta
I'm desperately trying to debug some problems I'm having with creating an manipulation of nodes in drupal 7 Services 3.
I've tried to insert a few debug statements to figure out where things are going wrong. When I create a node using poster (from the browser) it worked great, it prints the info I want.
When I do it from my app (iphone app), the same function is called, but the debug does not seem to print out to the page, even if I refresh it. I wonder what I am doing wrong.
Thanks
Solução
Standard debugging functions like dpm()
and dvm()
use the drupal_set_message()
function, which is tied to a user's session. When you try using the node form, you see the message because it is saved to your session. However, when you use the service via your iphone app, the messages get saved to a session that is probably not the one you're logged in under.
Fortunately, for situations like this, you can use the dd()
function, which will print the debugging information out to a file in the /tmp
directory, typically called drupal_debug.txt
.
[edit] I notice you're using the debug()
function, which triggers error handling, note that this also uses drupal_set_message()
, so the above is still relevant. (The dpm()
and dvm()
functions are from the Devel module.)
Outras dicas
You could also try using watchdog()
.
watchdog('debug', '<pre>'. print_r($example_array, TRUE) .'</pre>');