Re: [PHP] PHP Script/Thread ID thingie

2008-08-19 Thread Herman Gomez

Jochem Maas wrote:

[EMAIL PROTECTED] schreef:
I'm logging things with error_log, and would like to be able to sort 
out one script run from another.


So I'm looking for some kind of script id or thread id or PHP 
script run execution ID type of function.


getmypid() just returns the same apache child process ID all the time, 
so that's not what I want.


zend_thread_id() looks useful, but I suspect it's not quite what I'm 
looking for.  But I'd have to re-compile with ZTS and --debug-mode and 
I don't think the function I'm looking for should require that...


Perhaps I've just missed the right function name?

Or perhaps this should be a Feature Request?


might very well be. I've had thew same annoyance more than once ... my 
'solution' was to
use a wrapper for error_log() (you do that anyway right ;-) and have it 
prepend a per-request 'unique'
string to each log message (some timestamp/scriptname/random-value 
mashup) and then output that same
per-request 'unique' string at the bottom of each page (so that you can 
then use that value to

grep in the error log) ... not very satisfactory, but it works.

BTW, hi!








Following the wrapper idea, you can use the session ID. It's unique per 
user, no matter if they share the thread some times.


Regards,
Herman

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Conditional compilation

2008-08-15 Thread Herman Gomez

Hi,

Here is something I used to do in C/C++ to include/exclude automaticaly 
all debugging code at compiling time:


#define debug TRUE
#ifdef(debug)
//debugging code
#endif

That way I can include/exclude easily all debugging code in the final 
compiled code. In PHP I have not been able to find anything like that.
The only solution I've found is having this kind of code in every debug 
code block:


if ($debug) {
//debugging code
}

But this means that the debugging code is in the final compiled 
(interpreted) code, wasting cpu cycles even if there won't be any 
debugging in production.


Does somebody know if there is something like conditional compilation in 
PHP that I can use?


Regards,
Herman Gomez
Madrid, Spain.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php