[Drupal] How do I Debug Drupal Live sites?
Debugging is a process of finding and reducing the number of bugs. In the web applications development we used to work mostly on the development site at first and debug the errors then we will go for the live site to just push the modifications which we made in the development site. In such cases there may be a chance of error occurrence in the live site even if we come up from the development site. Then we have to handle the debugging process in the live site at that point of time. In the development site process we can do the debugging process easily, there is no need to worry about the customers since because it is not viewable to the customers. But when it comes to the live site we have to consider about the customers who visit the site.
Recently I have ran into a problem with a node in the live Drupal site as the content of the node was not displaying properly. So I need to print or dpm or watchdog the node object to findout the bug in drupal site. There are such cases there we need to do watchdog alone so there wont be any issue when we work it in a live since because the values are stored in the Reports->Recent log messages and it can be viewed only by the administrator user.
In such cases there may be a need of dpm or print functionalities there we need a safer debugging in the productive Drupal site. And while printing the values here I need two cases one as an authenticated user and the another one as an anonymous user.
global $user;
if ($user->uid == 1) {
// Do your debugging here for authenticated user.
// The user 1 indicates administrator so only admin can view the print message.
}
if(isset($_GET['debug'])) {
if($_GET['debug'] == 1) {
// Do your debugging here.
// By this method you can hard code the url and get the debugging.
// Like http://www.zyxware.com?debug=1
}
}