Re: Log_console Bug?

From: Date: Sat, 23 Apr 2005 20:40:34 +0000
Subject: Re: Log_console Bug?
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-37383@lists.php.net to get a copy of this message
On Fri, Apr 22, 2005 at 05:16:03PM +1000, Alex Hayes wrote: > I think there is a bug in Log_console, well at least there appears to be > one when using Fedora Core 3, php 5.0.3 In the future, please report bugs using the PEAR bug tracker: http://pear.php.net/bugs/ That will ensure that I won't miss your report. > For example: > > <code> > require "Log.php"; > > $logger = &Log::singleton('console', '', 'ident'); > for ($i = 0; $i < 10; $i++) { > $logger->log("Log entry $i"); > } > </code> > > Will produce: Warning: fwrite(): supplied argument is not a valid stream > resource in /usr/share/pear/Log/console.php on line 180 This code works correctly for me (under PHP 5.1.0-dev). > This is becuase on line 180 Log_console is attempting to do the following: > fwrite($this->_stream); (where stream is equal to the string STDOUT, not a > resource) My PHP environment disagrees: $ php -r "print_r(STDOUT);" Resource id #2 However, STDOUT is CLI-specific. Are you attempting to use the 'console' handling outside of the CLI environment? I can't see why that would be especially useful, but it wouldn't hurt to make the code more generic by explicitly opening the "php://stdout" input stream. Granted, if that's really the behavior you want, you can always specify the stream yourself, as you suggest. -- Jon Parise (jon of php.net) :: The PHP Project (http://www.php.net/)

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