Drupal: debugging to a file
Drupal and debugging often means using Devel, which ships with some
very useful functions like dpm()
, kpr()
, dpq()
and more for outputting debug stuff,
but these sometimes fail to display things on your site due to some reasons (e.g. called too
late, an issue with a template, AJAX…).
Devel ships with a bit more magic that can help though, you can simply use dd()
which “logs a variable to a drupal_debug.txt in the site’s temp directory”, so you can simply
do
1 2 | <?php dd('something'); |
in your code, and then tail -f /tmp/drupal_debug.txt
for live feed
of your debug goodies (or just open the file in an editor like a normal person).
Happy debugging!
Note: This is more-or-less a last resort help for me, I prefer using breakpoints
in my IDE which is way better and does not require knowing any of this. But I though
dd()
was cool as well :-).