Solved

Extend output from logging to include the .php file the line number in that php file variables and values used on that line

Posted on 2014-03-12
3
342 Views
Last Modified: 2014-03-17
I am very much of the opinion that you can't have too much information and either by extending the logging threshold values, outputting more or less data, or by analysis of the output to achieve what I want to see this time.

I would like to trace the path of my  code outputting parameters set or used is this possible and where would I start?

Thanks very much for listening I hope to hear from you

John
0
Comment
Question by:johnecollins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39923301
Yes, it is possible.  Nobody much does this any more, because object oriented design makes it unnecessary to trace logic - the amounts of code in any method are usually so small that "spaghetti logic" simply does not occur.  But that said, PHP has some tools that can help you do this.

There are the magic constants.  You can print or log these.
http://www.php.net/manual/en/language.constants.predefined.php

Data visualization is available with var_dump(). Especially useful for invisible variables like $_COOKIE and $_SESSION.
http://www.php.net/manual/en/function.var-dump.php

You can log any information you want with error_log()
http://www.php.net/manual/en/function.error-log.php

I have not used it (intentionally) but there is this:
http://www.php.net/manual/en/function.debug-backtrace.php

This article is a little old, but it hits many of the right notes.  Probably XDebug belongs on your short list:
http://coding.smashingmagazine.com/2009/01/20/50-extremely-useful-php-tools/

Since I began PHP before PHP4, I developed my own crude error handlers and tracing process.  In my ancient design, I would set a $debug variable in the script common logic.  And I had a debug() function that I called at various points throughout the script.  If the $debug variable was not set, the function did nothing.  If the $debug variable was set, the debug() function would gather and write a collection of data.  At the end of the script, if the $debug variable was set, the script would conclude by sending me an email message pointing to the file of debugging data.  None of this is necessary any more, since most of my work is OOP.
0
 

Author Closing Comment

by:johnecollins
ID: 39933569
Ray, thanks very much for your help I have had a good read and my knowledge has grown and helped me progress my development

Thanks a lot

John
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39933886
Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question