[Jifty-commit] r2688 - jifty/trunk/lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun Jan 28 09:35:51 EST 2007


Author: audreyt
Date: Sun Jan 28 09:35:50 2007
New Revision: 2688

Modified:
   jifty/trunk/lib/Jifty/Logger.pm

Log:
* Jifty::Logger - Properly respect previous $SIG{__WARN__} handler
  if Log4Perl isn't yet initialized; that means we won't silently
  discard compile-time errors from our model classes, though they
  are still demoted as warnings.

Modified: jifty/trunk/lib/Jifty/Logger.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Logger.pm	(original)
+++ jifty/trunk/lib/Jifty/Logger.pm	Sun Jan 28 09:35:50 2007
@@ -70,6 +70,7 @@
 =cut
 
 use Log::Log4perl;
+use Carp;
 
 use base qw/Jifty::Object/;
 
@@ -105,6 +106,7 @@
     
     # whenever Perl wants to warn something out capture it with a signal
     # handler and pass it to log4perl
+    my $previous_warning_handler = $SIG{__WARN__};
     $SIG{__WARN__} = sub {
 
         # This caller_depth line tells Log4perl to report
@@ -121,6 +123,15 @@
             my @lines = map {"$_"} @_;
             $logger->warn(map {chomp; $_} @lines);
         }
+        elsif ($previous_warning_handler) {
+            # Fallback to the old handler
+            goto &$previous_warning_handler;
+        }
+        else {
+            # Now handler - just carp about it for now
+            local $SIG{__WARN__};
+            carp(@_);
+        }
     };
 
     return $self;


More information about the Jifty-commit mailing list