Ticket #751 (closed defect: fixed)

Opened 9 months ago

Last modified 5 weeks ago

stdout/stderror log appenders are broken

Reported by: MikeSeth Owned by: david
Priority: low Milestone: 0.11.2
Component: logging Version: 0.11.0
Severity: minor Keywords: stderr stdout logging bug
Cc: Patch attached: yes

Description (last modified by david) (diff)

Trying to use stdout/stderror log appenders which rely on the php://foo naming convention for PHP streams results in:

Fatal error: Uncaught exception 'AgaviLoggingException' with message 'Cannot open file "php://stderr", please check permissions on file or directory.' in /usr/share/php/agavi/logging/AgaviFileLoggerAppender.class.php:75

Stack trace:

#0 /usr/share/php/agavi/logging/AgaviFileLoggerAppender.class.php(115): AgaviFileLoggerAppender->getHandle()

#1 /usr/share/php/agavi/logging/AgaviLogger.class.php(58): AgaviFileLoggerAppender->write(Object(AgaviLoggerMessage))

This is because in AgaviFileLoggerAppender's getHandle() no consideration is made towards the streams as the code asserts the file name passed to it is a physical file.

Attachments

patch for getHandle.diff (1.2 KB) - added by MikeSeth 9 months ago.
Fix for the stream problem in getHandle()
patch_751.diff (0.9 KB) - added by impl 9 months ago.

Change History

Changed 9 months ago by MikeSeth

Fix for the stream problem in getHandle()

Changed 9 months ago by david

  • owner changed from david to dominik
  • component changed from _OTHER_ to logging
  • description modified (diff)
  • severity changed from trivial to minor

Changed 9 months ago by david

Frankly, I don't think that's a proper solution to the problem. There might be other stream wrappers a person wants to use that do not support these kind of checks (is_writable() et al) either. Right?

Changed 9 months ago by impl

  • owner dominik deleted
  • has_patch set

Here's some strange behavior:

~ % php -r 'var_dump(fopen("php://stdout", "a"));'

Warning: fopen(): cannot seek on a pipe in Command line code on line 1
resource(5) of type (stream)

The PHP manual states that the php:// stream wrapper supports php://stdout, php://stderr, php://output, php://memory and php://temp for appending. Seems like it should be able to do this without a warning. Oh well. (http://php.net/wrappers.php)

AFAIK, there's no way to tell whether a given stream supports appending or not programmatically. Which kinda sucks. Anyway, see attached -- not tested, but seems like an okay solution to me.

Changed 9 months ago by impl

  • owner set to dominik

Changed 9 months ago by impl

Changed 9 months ago by david

  • milestone changed from 0.11.1 to 0.11.2

Changed 7 months ago by david

  • owner changed from dominik to david
  • status changed from new to assigned

Changed 7 months ago by david

  • status changed from assigned to closed
  • resolution set to fixed

(In [2522]) Fix #751: stdout/stderror log appenders are broken. To achieve this properly, I refactored AgaviLoggerAppender? to be an AgaviParameterHolder? (closes #774) and introduced an intermediate AgaviStreamLoggerAppender? to abstract things properly (closes #773). Just for the record, the error only appeared on Linux ;) so we now use "w" instead of "a" flags for std* fopen() calls.

Changed 5 weeks ago by david

(In [3397]) comment with url of PHP bug ticket explaining why we use "w" and not "a" modes for stdout and stderr logger appenders, refs #751

Add/Change #751 (stdout/stderror log appenders are broken)

Author



Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.