Re: Log->setIdent not behaving as I thought it would...
| From: | Alex Hayes | Date: | Mon, 09 Jun 2003 22:02:31 +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-17225@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!!)
>
>
> thanks
> alex
>
Ive had a quickish.. look at this strange behaviour and havent been able to
crack it yet..... however I was wondering if there was a possibility of
added a small feature to the log classes. Just a small feature so that we
can also set up a line feed in the $conf array.
For example..
$conf = array('mode' => 0600, 'linefeed' => "\n");
$log_file = &Log::singleton('file', 'log.log', 'IDENT', $conf,
PEAR_LOG_INFO);
....
Then in our log classes we would need to do something like...
Log/file.php line 67 - add
====== 8< ========
/**
* String containing the logfile's line feed (character return).
* @var string
*/
var $_linefeed = "\r\n";
====== >8 ========
Log/file.php line 107 - add
====== 8< ========
/* If a file line feed has been provided, use it. */
if (!empty($conf['linefeed'])) {
$this->_linefeed = $conf['linefeed'];
}
====== >8 ========
Log/file.php line 247 - modify
====== 8< ========
return fwrite($this->_fp, sprintf("%s %s [%s] %s" . $this->_linefeed,
$time, $ident, $this->priorityToString($priority), $line));
====== >8 ========
This feature would also need to be added to the mail class, which currently
uses \n for line feeds.
thanks
alex