Re: Log->setIdent not behaving as I thought it would...

From: Date: Mon, 09 Jun 2003 23:46:24 +0000
Subject: Re: Log->setIdent not behaving as I thought it would...
References: 1 2 3 4  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-17231@lists.php.net to get a copy of this message
> Actually I think there is a problem in the composite implementation as well. > > > Reason I say this is because when I run the following.. > > $log = &Log::singleton('composite'); > $log_file = &Log::singleton('file', 'log.log', 'IDENT', > $conf,PEAR_LOG_INFO); > $log_mail = &Log::singleton('mail', 'me@myaddress.com', > 'IDENT', > $conf,PEAR_LOG_WARNING); > $log->addChild($log_file); > $log->addChild($log_mail); > > for ($i = 0; $i < 12; $i++) { > $log->setIdent("ITEM".$i); > $log->log("Foo: $i", $i); > } > > $log->close(); > > It doesnt set the identity either.... > > However if I just run.. > > for ($i = 0; $i < 12; $i++) { > $log_file->setIdent("ITEM".$i); > $log_file->log("Foo: $i", $i); > } > > it behaves as expected (now, thankyou!!) I figured out a way to fix this problem. its a bit of a hack tho.. :| but it seems to work.... although I cannot figure out why the old way is not working. file Log/composite.php line 97 - add ---------- 8< ----------- /** * Sets each child of this composite's identification string. * * @param string $ident The new identification string * * @access public */ function setIdent($ident) { foreach ($this->_children as $id => $child) { $this->_children[$id]->_ident = $ident; } } ---------- >8 ----------- what do you think Jon? It seems like varibles from the class are being copied (ie.. when we set the Ident for the composite class, it does not set the Ident for its children....), even tho the class is referenced?? excuse my terminology, i hope this makes some sense....

« previous php.pear.dev (#17231) next »