Raised exceptions are not logged when USR2

Iñaki Baz Castillo ibc at aliax.net
Mon Jan 4 17:14:52 EST 2010

El Domingo, 3 de Enero de 2010, Eric Wong escribió:

>   # Totally untested, stick this in your Unicorn config file and let
>   # us know if it works or blows up badly:
>   require 'syslog_logger'
>   class MySyslogLogger < SyslogLogger
>     alias puts error
>     alias write error
>     def flush; self; end
>   end
>   $stderr = MySyslogLogger.new('foo')

Unfortunatelly it doesn'w work very well. First of all Sysloglogger relies on 
a constant called SYSLOG created in "initialize" method so it's required to 
add the above methods to SyslogLogger class rather than subclass.

Anyhow, the main problem is that by doing "$stderr = SyslogLogger.new('foo')" 
the std error is not redirected as /proc/PID/fd still shows:

  2 -> /dev/pts/2

Of course by calling $stderr.puts "error" the above works, but when a real 
error raised it's is printed in the screen (/dev/pts/2).

I strongly think that IO#reopen is required. IO#reopen accepts a string (file 
path) or other IO, so "converting" SyslogLogger into a IO is required.

I'll try to achieve it.


Iñaki Baz Castillo <ibc at aliax.net>

More information about the mongrel-unicorn mailing list