You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Stas Bekman <st...@stason.org> on 2004/06/02 19:06:54 UTC

[Fwd: Re: [mp2][PATCH] enhancement for Apache::Reload]

Looks good Andreas, Thank you! I'm forwarding this to the dev list.

Anybody has issues with this change? I'd probably do a little tweak to the 
code, but otherwise looks good. Might reuse Apache::TestTrace for this 
functionality.

-------- Original Message --------
Subject: Re: [mp2][PATCH] enhancement for Apache::Reload
Date: Tue, 1 Jun 2004 15:01:07 +0200
From: Andreas Bauer <ab...@suse.de>
Reply-To: abauer@suse.de
To: Stas Bekman <st...@stason.org>
CC: modperl@perl.apache.org
References: <20...@suse.de> <40...@stason.org>

Hi Stas,
sorry for the delay.

On Friday 14 May 2004 20:14, Stas Bekman wrote:
>
> It could be better to have:
>
> PerlSetVar ReloadTrace debug
> PerlSetVar ReloadTrace info
> PerlSetVar ReloadTrace error
>
> etc. but I don't think we will need more than 2. Whichever way is fine with
> me. As this is mp2 we can change the API as long as 2.0 is not released. So
> may be it's better to go with the second idea.

Ok, I did the ReloadTrace thing with 'info' and 'debug' as possible values. It
should not be difficult to add support for more values.

> And docs live here:
> http://perl.apache.org/docs/2.0/api/Apache/Reload.pod.orig

Reload.pm patch:

--- Reload.pm.orig      2004-06-01 14:31:33.133067240 +0200
+++ Reload.pm   2004-06-01 13:54:34.690321800 +0200
@@ -59,7 +59,11 @@ sub handler {
      my $o = shift;
      $o = $o->base_server if ref($o) eq 'Apache::Connection';

+    my %TRLEV = (''=>0, 'info'=>1, 'debug'=>2);
      my $DEBUG = ref($o) && (lc($o->dir_config("ReloadDebug") || '') eq 'on');
+    my $TRACE = ref($o) && lc($o->dir_config("ReloadTrace"));
+    my $trlev = $TRLEV{($TRACE || ($DEBUG ? 'debug' : ''))};

      my $TouchFile = ref($o) && $o->dir_config("ReloadTouchFile");

@@ -70,7 +74,7 @@ sub handler {
      my $TouchModules;

      if ($TouchFile) {
-        warn "Checking mtime of $TouchFile\n" if $DEBUG;
+        warn "Checking mtime of $TouchFile\n" if $trlev >= $TRLEV{debug};
          my $touch_mtime = (stat($TouchFile))[9] || return 1;
          return 1 unless $touch_mtime > $TouchTime;
          $TouchTime = $touch_mtime;
@@ -119,7 +123,7 @@ sub handler {
      while (my($key, $file) = each %Apache::Reload::INCS) {
          next unless defined $file;
          next if @watch_dirs && !grep { $file =~ /^$_/ } @watch_dirs;
-        warn "Apache::Reload: Checking mtime of $key\n" if $DEBUG;
+        warn "Apache::Reload: Checking mtime of $key\n" if $trlev >= 
$TRLEV{debug};

          my $mtime = (stat $file)[9];

@@ -150,7 +154,7 @@ sub handler {
                  unless $ConstantRedefineWarnings;
              require $key;
              warn("Apache::Reload: process $$ reloading $key\n")
-                    if $DEBUG;
+                    if $trlev >= $TRLEV{info};
          }
          $Stat{$file} = $mtime;
      }



Reload.pod patch:

--- Reload.pod.orig	2004-06-01 14:23:28.675715952 +0200
+++ Reload.pod.new	2004-06-01 14:23:23.339527176 +0200
@@ -18,7 +18,7 @@
    PerlInitHandler Apache::Reload
    PerlSetVar ReloadAll Off
    PerlSetVar ReloadModules "ModPerl::* Apache::*"
-  #PerlSetVar ReloadDebug On
+  #PerlSetVar ReloadTrace Info
    #PerlSetVar ReloadConstantRedefineWarnings Off

    # Reload a single module from within itself:
@@ -183,9 +183,19 @@
  =head1 Debug

  If you aren't sure whether the modules that are supposed to be
-reloaded, are actually getting reloaded, turn the debug mode on:
+reloaded, are actually getting reloaded, set the C<ReloadTrace>
+variable:

-  PerlSetVar ReloadDebug On
+  PerlSetVar ReloadTrace Info
+
+To further increase the log output, e.g. showing information about
+the files that are checked for reloading:
+
+  PerlSetVar ReloadTrace Debug
+
+The C<ReloadDebug> variable used in C<Apache::Reload> v0.09 and
+earlier is still supported for backward compatibility but usage
+is discouraged. It will probably be removed in the future.

  =head1 Silencing 'Constant subroutine ... redefined at' Warnings

> Thanks.

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Fwd: Re: [mp2][PATCH] enhancement for Apache::Reload]

Posted by Stas Bekman <st...@stason.org>.
Geoffrey Young wrote:
> 
> Stas Bekman wrote:
> 
>>Looks good Andreas, Thank you! I'm forwarding this to the dev list.
>>
>>Anybody has issues with this change? 
> 
> 
> assuming it works, it sounds fine.  I don't have the free tuits to test it atm.

Same here. I'll probably get to polish it once I've delivered my tutorial 
material.

>>I'd probably do a little tweak to
>>the code, but otherwise looks good. Might reuse Apache::TestTrace for
>>this functionality.
> 
> 
> well, you probably don't want to use Apache::TestTrace in code that exists
> outside of the test system since they are different projects - presumably we
> could remove the entire test framework and move to something else, but
> Apache::Reload would still require part of A-T to function, which would be
> kinda strange.

Right. But we could still copy most of the code from there. i.e. replace those 
explicit:

   print ... if $debug > ...;

with debug level wrappers functions, which I'm now used to and love them.

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Re: [Fwd: Re: [mp2][PATCH] enhancement for Apache::Reload]

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Stas Bekman wrote:
> Looks good Andreas, Thank you! I'm forwarding this to the dev list.
> 
> Anybody has issues with this change? 

assuming it works, it sounds fine.  I don't have the free tuits to test it atm.

> I'd probably do a little tweak to
> the code, but otherwise looks good. Might reuse Apache::TestTrace for
> this functionality.

well, you probably don't want to use Apache::TestTrace in code that exists
outside of the test system since they are different projects - presumably we
could remove the entire test framework and move to something else, but
Apache::Reload would still require part of A-T to function, which would be
kinda strange.

--Geoff

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org