Welcome to Geeklog Friday, November 24 2017 @ 06:02 am EST

Debugging ideas

  • Contributed by:
  • Views: 3,455
Geeklog For users that are modifying geeklog or integrating other components, the following are ideas to assist in debugging. It's hard to make assumptions on your skill level and not talk down or be too assumptive. You will need a basic understanding of syntax and of course know where you want to place the debug statements and what to display. Start basic and work your way up.

There are a few options but essentially, you are looking to add some output to tell you if the program is executing certain sections of code (am I here or here..) and the value of variables. I'll try to break it down as follows:

  1. You can use echo - this will appear at the top of your geeklog site output and may generate a HEADER related errro message. Examples:
    - echo "I am here ...";
    - echo "The value of uid is: " . $uid;
    - echo "The value of GEEKLOG_DIR is: " . $GEEKLOG_DIR;

  2. Use the COM_errorLOG function in lib-common.php, which writes to the /logs/error.log file. Examples:
    - COM_errorLOG("Inside the gallery init.php - geeklog code section");
    - COM_errorLOG("The value of CONF['theme'] is: " . $_CONF['theme'];
    - COM_errorLOG("Inside Lib-Common: USER[UID] is: ".$_USER['uid'] . ", Username is: ". $_USER['username'] . ", uid is: ". $uid);

  3. Use the var_dump() function to dump the value of a variable or array. Examples:
    - var_dump($_CONF);
    - var_dump($uid);
    - var_dump($HTTP_GET_VARS);

  4. Use my contributed debugBlock and function call to output to a block on your main page. Similar to using COM_errorLOG but you don't have to be tail'ing (watching) a logfile or require lib-common.php. Example:
    - phpblock_debugWrite(" User ID is: " . $_USER['uid']);


You can see how you concatenate variables and text in quotes using the "."
There are other options with integrated debugging environments but this is the how you would start, IMHO anyways.

Cheers,
Blaine