[Jifty-commit] r2689 - in jifty/branches/virtual-models: lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun Jan 28 09:38:49 EST 2007


Author: jesse
Date: Sun Jan 28 09:38:49 2007
New Revision: 2689

Modified:
   jifty/branches/virtual-models/   (props changed)
   jifty/branches/virtual-models/lib/Jifty/Logger.pm

Log:
 r21625 at hualien (orig r2688):  audreyt | 2007-01-28 22:35:50 +0800
 * 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/branches/virtual-models/lib/Jifty/Logger.pm
==============================================================================
--- jifty/branches/virtual-models/lib/Jifty/Logger.pm	(original)
+++ jifty/branches/virtual-models/lib/Jifty/Logger.pm	Sun Jan 28 09:38:49 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