[Jifty-commit] r1810 - in jifty/trunk: lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Aug 14 08:35:40 EDT 2006


Author: mark
Date: Mon Aug 14 08:35:36 2006
New Revision: 1810

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Logger.pm

Log:
 r1560 at travis:  mark | 2006-08-11 20:31:13 +0100
 reorder of code to make it clearer what's happening


Modified: jifty/trunk/lib/Jifty/Logger.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Logger.pm	(original)
+++ jifty/trunk/lib/Jifty/Logger.pm	Mon Aug 14 08:35:36 2006
@@ -40,28 +40,16 @@
 
     $component = '' unless defined $component;
 
-    my $log_config
-        = Jifty::Util->absolute_path( Jifty->config->framework('LogConfig') );
+    # configure Log::Log4perl unless we've done it already
     if (not Log::Log4perl->initialized) {
-        if ( defined Jifty->config->framework('LogReload') ) {
-            Log::Log4perl->init_and_watch( $log_config,
-                Jifty->config->framework('LogReload') );
-        } elsif ( -f $log_config and -r $log_config ) {
-            Log::Log4perl->init($log_config);
-        } else {
-            my $log_level = Jifty->config->framework('LogLevel');
-            my %default = (
-                'log4perl.rootLogger'        => "$log_level,Screen",
-                '#log4perl.logger.SchemaTool' => "$log_level,Screen",
-                'log4perl.appender.Screen'   => 'Log::Log4perl::Appender::Screen',
-                'log4perl.appender.Screen.stderr' => 1,
-                'log4perl.appender.Screen.layout' =>
-                    'Log::Log4perl::Layout::SimpleLayout'
-            );
-            Log::Log4perl->init( \%default );
-        }
+       $class->_initialize_log4perl;
     }
+    
+    # create a log4perl object that answers to this component name
     my $logger = Log::Log4perl->get_logger($component);
+    
+    # whenever Perl wants to warn something out capture it with a signal
+    # handler and pass it to log4perl
     $SIG{__WARN__} = sub {
 
         # This caller_depth line tells Log4perl to report
@@ -83,6 +71,31 @@
     return $self;
 }
 
+sub _initialize_log4perl {
+    my $class = shift;
+  
+    my $log_config
+        = Jifty::Util->absolute_path( Jifty->config->framework('LogConfig') );
+
+    if ( defined Jifty->config->framework('LogReload') ) {
+        Log::Log4perl->init_and_watch( $log_config,
+            Jifty->config->framework('LogReload') );
+    } elsif ( -f $log_config and -r $log_config ) {
+        Log::Log4perl->init($log_config);
+    } else {
+        my $log_level = Jifty->config->framework('LogLevel');
+        my %default = (
+            'log4perl.rootLogger'        => "$log_level,Screen",
+            '#log4perl.logger.SchemaTool' => "$log_level,Screen",
+            'log4perl.appender.Screen'   => 'Log::Log4perl::Appender::Screen',
+            'log4perl.appender.Screen.stderr' => 1,
+            'log4perl.appender.Screen.layout' =>
+                'Log::Log4perl::Layout::SimpleLayout'
+        );
+        Log::Log4perl->init( \%default );
+  }
+}
+
 =head1 AUTHOR
 
 Various folks at Best Practical Solutions, LLC.


More information about the Jifty-commit mailing list