Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > PHP- Anyway to "echo" to the console?

PHP- Anyway to "echo" to the console?
Thread Tools
osxisfun
Registered User
Join Date: Apr 2003
Location: The Internets
Status: Offline
Reply With Quote
Mar 15, 2005, 04:02 PM
 
I was wondering if anyone knew of a way or an extension that would allow some sort of debugging to the OSX console app.

like

<?php

echoMyConsole("this is text");

?>

But instead of echoing to the page the "this is text" code would go to OSX's console ouput?


thanks
     
leira
Junior Member
Join Date: May 2004
Status: Offline
Reply With Quote
Mar 16, 2005, 01:00 AM
 
this will divert errors that normally go into httpd.log and puts them into a csv file.
Code:
<?php // Write php errors to log file instead of apache log error_reporting(0); $old_error_handler = set_error_handler("userErrorHandler"); function userErrorHandler ($errno, $errmsg, $filename, $linenum, $vars){ $time=date("d M Y H:i:s"); // Get the error type from the error number $errortype = array (1 => "Error", 2 => "Warning", 4 => "Parsing Error", 8 => "Notice", 16 => "Core Error", 32 => "Core Warning", 64 => "Compile Error", 128 => "Compile Warning", 256 => "User Error", 512 => "User Warning", 1024 => "User Notice"); $errlevel=$errortype[$errno]; //Write error to log file (CSV format) $errfile=fopen("php_errors.csv","a"); fputs($errfile,"\"$time\",\"$filename: line:$linenum\",\"($errlevel) $errmsg\"\n\n"); fclose($errfile); if($errno!=2 && $errno!=8) { //Terminate script if fatal errror die("A fatal error has occured. Script execution has been aborted"); } } ?>
     
osxisfun  (op)
Registered User
Join Date: Apr 2003
Location: The Internets
Status: Offline
Reply With Quote
Mar 16, 2005, 03:48 PM
 
thank you!.

so this will output the error to a text file? (little confused by the CVS label.)

awesome. i can then leave this file open in my text editor and it will auto update its contents.
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Mar 16, 2005, 04:08 PM
 
Not CVS, CSV.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
osxisfun  (op)
Registered User
Join Date: Apr 2003
Location: The Internets
Status: Offline
Reply With Quote
Mar 16, 2005, 04:10 PM
 
Originally posted by Chuckit:
Not CVS, CSV.
Doh! That's what i thought at first but then my current chest cold took over my thoughts..


Thanks all!
     
ameat
Dedicated MacNNer
Join Date: Feb 2001
Location: Manhattan
Status: Offline
Reply With Quote
Mar 17, 2005, 01:57 PM
 
you can set the console to view other log files besides the main system log.

Go to:
Code:
File > Open Quickly > /var/log > httpd > ...
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:29 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,