Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > PHP Script/Thread ID thingie
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 29th April 06:20
External User
 
Posts: 1
Default PHP Script/Thread ID thingie



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"?
  Reply With Quote


  sponsored links


2 29th April 06:20
stuttle
External User
 
Posts: 1
Default PHP Script/Thread ID thingie



Don't think there is such a thing, but you could generate one by
combining the pid, timestamp and the script filename, maybe into an
md5 hash value or similar. Thinking about it, "ip.pid" would be
enough, i.e. 127.0.0.1.12345.

-Stut

--
http://stut.net/
  Reply With Quote
3 29th April 06:20
eric.butera
External User
 
Posts: 1
Default PHP Script/Thread ID thingie


I suppose if nobody else has better ideas you can fake it with setting
some sort of unique value and combining that with __FILE__ for your
instance run.

<?php
$GLOBALS['instance'] = md5(uniqid());
error_log(__FILE__.$GLOBALS['instance'].' first log'); error_log(__FILE__.$GLOBALS['instance'].' second log');
?>

Not very glamorous though.
  Reply With Quote
4 29th April 09:32
ceo
External User
 
Posts: 1
Default PHP Script/Thread ID thingie


The IP and pid will not actually change...

It's just me surfing to my own app (or one I inherited) on my own
desktop.

Apache isn't getting nearly exercised enough to need a second child,
so the pid is the same all the time...

Guess I'll have to create one as Eric Butera suggested...

Seems kind of odd that there isn't some kind of
script/thread/M_INIT/R_INIT id hanging around and exposed that
developers could use.
[shrug]

--
Some people ask for gifts here.
I just want you to buy an Indie CD for yourself:
http://cdbaby.com/search/from/lynch
  Reply With Quote
5 29th April 09:32
stuttle
External User
 
Posts: 1
Default PHP Script/Thread ID thingie


I don't find that odd since there's on external context to such an ID
other than that which you create within the script so you can just use
something randomly unique.

-Stut

--
http://stut.net/
  Reply With Quote
6 29th April 16:37
jochem
External User
 
Posts: 1
Default PHP Script/Thread ID thingie


ceo@l-i-e.com schreef:


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!
  Reply With Quote
7 29th April 19:59
herman_internet
External User
 
Posts: 1
Default PHP Script/Thread ID thingie


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
  Reply With Quote
8 29th April 19:59
jochem
External User
 
Posts: 1
Default PHP Script/Thread ID thingie


Herman Gomez schreef:


d'oh ... looking back at the code I was thinking of I actually used the session ID!
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666