[Rt-commit] rt branch, 4.0/rename-LogToScreen, created. rt-3.9.7-1141-g9ee4377

Thomas Sibley trs at bestpractical.com
Thu Dec 30 19:38:01 EST 2010


The branch, 4.0/rename-LogToScreen has been created
        at  9ee4377b16836db11f29c8cd9456c1abfa00a4bd (commit)

- Log -----------------------------------------------------------------
commit 9ee4377b16836db11f29c8cd9456c1abfa00a4bd
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Dec 30 19:32:41 2010 -0500

    Rename $LogToScreen to $LogToSTDERR, but maintain back compat
    
    This creates a new hook for config options called PostSet which is
    passed the raw new and old values.

diff --git a/docs/UPGRADING-4.0 b/docs/UPGRADING-4.0
index 10d9b81..91aa5ff 100644
--- a/docs/UPGRADING-4.0
+++ b/docs/UPGRADING-4.0
@@ -16,6 +16,14 @@ server configuration.  You need to review docs/web_deployment.pod for current
 instructions
 
 *******
+UPGRADING FROM RT 4.0.0 and greater
+
+* The $LogToScreen config setting is now named $LogToSTDERR which better
+  describes what the log level controls.  Setting $LogToScreen will still work,
+  but an informational notice will be issued on server start telling you about
+  the rename.  To avoid this you should set $LogToSTDERR instead.
+
+*******
 UPGRADING FROM RT 3.8.x and RTFM 2.1 or greater
 
 RT4 now includes an Articles functionality, merged from RTFM.
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 74bf759..3d1c23d 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -775,7 +775,7 @@ log message.
 
 =over 4
 
-=item C<$LogToSyslog>, C<$LogToScreen>
+=item C<$LogToSyslog>, C<$LogToSTDERR>
 
 The minimum level error that will be logged to the specific device.
 From lowest to highest priority, the levels are:
@@ -784,7 +784,7 @@ From lowest to highest priority, the levels are:
 =cut
 
 Set($LogToSyslog    , 'info');
-Set($LogToScreen    , 'info');
+Set($LogToSTDERR    , 'info');
 
 =item C<$LogToFile>, C<$LogDir>, C<$LogToFileNamed>
 
diff --git a/etc/upgrade/generate-rtaddressregexp.in b/etc/upgrade/generate-rtaddressregexp.in
index 2e81fb0..f91d037 100644
--- a/etc/upgrade/generate-rtaddressregexp.in
+++ b/etc/upgrade/generate-rtaddressregexp.in
@@ -54,7 +54,7 @@ use lib "@RT_LIB_PATH@";
 
 use RT;
 RT::LoadConfig();
-RT->Config->Set('LogToScreen' => 'debug');
+RT->Config->Set('LogToSTDERR' => 'debug');
 RT::Init();
 
 $| = 1;
diff --git a/etc/upgrade/shrink_cgm_table.pl b/etc/upgrade/shrink_cgm_table.pl
index 2954d48..77b2eb1 100644
--- a/etc/upgrade/shrink_cgm_table.pl
+++ b/etc/upgrade/shrink_cgm_table.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use RT;
 RT::LoadConfig();
-RT->Config->Set('LogToScreen' => 'debug');
+RT->Config->Set('LogToSTDERR' => 'debug');
 RT::Init();
 
 use RT::CachedGroupMembers;
diff --git a/etc/upgrade/shrink_transactions_table.pl b/etc/upgrade/shrink_transactions_table.pl
index 2599dc6..a4e9ff6 100644
--- a/etc/upgrade/shrink_transactions_table.pl
+++ b/etc/upgrade/shrink_transactions_table.pl
@@ -6,7 +6,7 @@ use warnings;
 
 use RT;
 RT::LoadConfig();
-RT->Config->Set('LogToScreen' => 'debug');
+RT->Config->Set('LogToSTDERR' => 'debug');
 RT::Init();
 
 use RT::Transactions;
diff --git a/etc/upgrade/split-out-cf-categories.in b/etc/upgrade/split-out-cf-categories.in
index 7edd952..84fda37 100644
--- a/etc/upgrade/split-out-cf-categories.in
+++ b/etc/upgrade/split-out-cf-categories.in
@@ -54,7 +54,7 @@ use lib "@RT_LIB_PATH@";
 
 use RT;
 RT::LoadConfig();
-RT->Config->Set('LogToScreen' => 'debug');
+RT->Config->Set('LogToSTDERR' => 'debug');
 RT::Init();
 
 $| = 1;
@@ -168,4 +168,4 @@ while (my $cf  = $CFs->Next ) {
 }
 
 $RT::Handle->Commit;
-print "No custom fields with categories found\n" unless $seen;
\ No newline at end of file
+print "No custom fields with categories found\n" unless $seen;
diff --git a/lib/RT.pm b/lib/RT.pm
index 865bc02..91db280 100644
--- a/lib/RT.pm
+++ b/lib/RT.pm
@@ -287,11 +287,11 @@ sub InitLogging {
                              callbacks => [ $simple_cb, $stack_cb ],
                            ));
         }
-        if ( $Config->Get('LogToScreen') ) {
+        if ( $Config->Get('LogToSTDERR') ) {
             require Log::Dispatch::Screen;
             $RT::Logger->add( Log::Dispatch::Screen->new
                          ( name => 'screen',
-                           min_level => $Config->Get('LogToScreen'),
+                           min_level => $Config->Get('LogToSTDERR'),
                            callbacks => [ $simple_cb, $stack_cb ],
                            stderr => 1,
                          ));
diff --git a/lib/RT/Config.pm b/lib/RT/Config.pm
index 64798a2..ca9cdb6 100644
--- a/lib/RT/Config.pm
+++ b/lib/RT/Config.pm
@@ -122,6 +122,11 @@ can be set for each config optin:
     Callback    - subref that receives no arguments.  It returns
                   a hashref of items that are added to the rest
                   of the WidgetArguments
+ PostSet       - subref passed the RT::Config object and the current and
+                 previous setting of the config option.  This is called well
+                 before much of RT's subsystems are initialized, so what you
+                 can do here is pretty limited.  It's mostly useful for
+                 effecting the value of other config options early.
  PostLoadCheck - subref passed the RT::Config object and the current
                  setting of the config option.  Can make further checks
                  (such as seeing if a library is installed) and then change
@@ -536,6 +541,22 @@ our %META = (
                               'You can change the site default in your %Lifecycles config.');
         }
     },
+    LogToScreen => {
+        PostSet => sub {
+            my $self  = shift;
+            my $value = shift;
+            $self->SetFromConfig(
+                Option => \'LogToSTDERR',
+                Value  => [$value],
+                %{$self->Meta('LogToScreen')->{'Source'}}
+            );
+        },
+        PostLoadCheck => sub {
+            my $self = shift;
+            $RT::Logger->info("You set \$LogToScreen in your config, but it's been renamed to \$LogToSTDERR.  Please update your config.")
+                if $self->Meta('LogToScreen')->{'Source'}{'Package'};
+        },
+    },
 );
 my %OPTIONS = ();
 
@@ -828,6 +849,8 @@ sub Set {
         {no warnings 'once'; no strict 'refs'; ${"RT::$name"} = $OPTIONS{$name}; }
     }
     $META{$name}->{'Type'} = $type;
+    $META{$name}->{'PostSet'}->($self, $OPTIONS{$name}, $old)
+        if $META{$name}->{'PostSet'};
     return $self->_ReturnValue( $old, $type );
 }
 
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 2833b90..a4933df 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -299,7 +299,7 @@ sub bootstrap_logging {
 
     print $config <<END;
 Set( \$LogToSyslog , undef);
-Set( \$LogToScreen , "warning");
+Set( \$LogToSTDERR , "warning");
 Set( \$LogToFile, 'debug' );
 Set( \$LogDir, q{$tmp{'directory'}} );
 Set( \$LogToFileNamed, 'rt.debug.log' );
diff --git a/t/approval/admincc.t b/t/approval/admincc.t
index b439296..3062ce5 100644
--- a/t/approval/admincc.t
+++ b/t/approval/admincc.t
@@ -12,7 +12,7 @@ use RT;
 use RT::Test tests => 62;
 use RT::Test::Email;
 
-RT->Config->Set( LogToScreen => 'debug' );
+RT->Config->Set( LogToSTDERR => 'debug' );
 RT->Config->Set( UseTransactionBatch => 1 );
 my ($baseurl, $m) = RT::Test->started_ok;
 
diff --git a/t/approval/basic.t b/t/approval/basic.t
index 2d00eb5..92ffc42 100644
--- a/t/approval/basic.t
+++ b/t/approval/basic.t
@@ -9,7 +9,7 @@ BEGIN {
 
 use RT::Test::Email;
 
-RT->Config->Set( LogToScreen => 'debug' );
+RT->Config->Set( LogToSTDERR => 'debug' );
 RT->Config->Set( UseTransactionBatch => 1 );
 
 my $q = RT::Queue->new(RT->SystemUser);
diff --git a/t/shredder/utils.pl b/t/shredder/utils.pl
index 34e6564..6e6f2e8 100644
--- a/t/shredder/utils.pl
+++ b/t/shredder/utils.pl
@@ -90,7 +90,7 @@ sub rewrite_rtconfig
 
     # generic logging
     config_set( '$LogToSyslog'    , undef );
-    config_set( '$LogToScreen'    , 'error' );
+    config_set( '$LogToSTDERR'    , 'error' );
     config_set( '$LogStackTraces' , 'crit' );
     # logging to standalone file
     config_set( '$LogToFile'      , 'debug' );

-----------------------------------------------------------------------


More information about the Rt-commit mailing list