Drupal debugging tip – use the logging console
I recently ran across a feature of Drupal's devel.module that might not be all that well known, namely that it has a facility for debug logging as well as the dpm() I've advocated to my fellow developers for a long time.
That is the dd()-command which instead of logging to screen simply outputs a print_r() to a file called drupal-debug.txt in your temporary files folder (where that is depends on your site configuration, but /tmp might be a good place to look).
That alleviates the many problems of simply logging to screen (doesn't work with AJAX, redirects, causes browser slowness for large datasets, lots of junk in your HTML source, etc.). You can then simply run tail -f /tmp/drupal-debug.txt to see what's going on – and for those of you that use Mac OS X, I have an additional trick.
OS X ships with a fairly good log viewer, namely Console.app – by default, it's installed in Applications/Utilities. That can be used to view all the logs in standard locations, but with a little trick, it can be used to view this log file also.
Console has a section for ~/Library/Log, ie. the Log folder in the Library folder in your home folder. You can then set up a symbolic link to the log file there. I have a subfolder in ~/Library/Log called apache2, and I also have my Apache log files symlinked in there as well.
Anyways, the procedure to set it up looks like this:
cd ~/Library/Logs/
ln -s /tmp/drupal_debug.txt
And the result looks like this:

-
Don't forget krumo()!
Thanks for this. It's something I never knew and will prove very useful. Another underrated feature of the devel module is the krumo() function which is like print_r() but compacts everything into a nice expanding hierarchy so you don't have to scroll for large arrays.
By the way, your 'sign in using OpenID' button links to a 404.
-
Another underrated feature of
Another underrated feature of the devel module is the krumo()
The
dpm()command automatically uses krumo for complex structures – objects, arrays etc.‘sign in using OpenID’ button links to a 404
You are not perchance using NoScript or similar to disable JavaScript on the page? It has a jQuery hijax-thing that transform the login-box on click, so if you're not seeing that, there's something wrong :)
-
FirePHP: keep your UI clean as a whistle
Why not avoid all the trouble of separate files and UI pollution by debug output and use [HTML_REMOVED]firephp[HTML_REMOVED] instead?
Install the base class under: devel/FirePHP and have all the debug output appear in the Firebug console.
Your OpenID login doesn't work. There's a problem in the redirect URL. Yes I have JS enabled.
There's some problem in the URL (encoding issues perhaps) it points to [HTML_REMOVED]http://mikkel.hoegh.org/%2523[HTML_REMOVED] when I click the OpenID icon in the login dialog.
-
Why not avoid all the trouble
Why not avoid all the trouble of separate files and UI pollution by debug output and use firephp instead?
Two reasons:
- Firefox is required, and FirePHP has historically not always had a release compatible with the newest version of Firefox. Plus, I do most of my development in Webkit.
- Once you refresh the page, that debug-info is gone. It's nice to have a log so you can easily compare the output between changes.
Your OpenID login doesn’t work. There’s a problem in the redirect URL. Yes I have JS enabled.
That is rather strange, since it works quite well in all my browsers… I'll take a look at it later, I'm building a new theme for this site anyways :)