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
328 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
  • 2
3 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
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
Comment Utility
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 108

Expert Comment

by:Ray Paseur
Comment Utility
Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now