[prev in list] [next in list] [prev in thread] [next in thread]
List: apache-test-cvs
Subject: cvs commit: httpd-test/perl-framework/Apache-Test/lib/Apache TestConfigPerl.pm TestRun.pm TestRunPer
From: stas () apache ! org
Date: 2003-05-14 1:12:23
[Download RAW message or body]
stas 2003/05/13 18:12:22
Modified: perl-framework/Apache-Test/lib/Apache TestConfigPerl.pm
TestRun.pm TestRunPerl.pm TestTrace.pm
Log:
introduce a new env var APACHE_TEST_TRACE_LEVEL, to override the trace
level. Propogate the overriden values (either by env var
APACHE_TEST_TRACE_LEVEL or -trace option) to the server-side, so we
can use tracing in the handlers, and enable disable traces from the
commmand line. This way we don't have to comment out debug
tracing.
Revision Changes Path
1.74 +6 -0 httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm
Index: TestConfigPerl.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestConfigPerl.pm,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- TestConfigPerl.pm 1 May 2003 06:22:18 -0000 1.73
+++ TestConfigPerl.pm 14 May 2003 01:12:21 -0000 1.74
@@ -122,6 +122,12 @@
close $fh or die "close $t: $!";
}
+# propogate trace overrides to the server
+sub configure_trace {
+ my $self = shift;
+ $self->postamble(PerlPassEnv => 'APACHE_TEST_TRACE_LEVEL');
+}
+
sub startup_pl_code {
my $self = shift;
my $serverroot = $self->{vars}->{serverroot};
1.109 +3 -0 httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm
Index: TestRun.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- TestRun.pm 1 May 2003 06:22:35 -0000 1.108
+++ TestRun.pm 14 May 2003 01:12:21 -0000 1.109
@@ -221,6 +221,9 @@
my %levels = map {$_ => 1} @Apache::TestTrace::Levels;
if (exists $levels{ $opts{trace} }) {
$Apache::TestTrace::Level = $opts{trace};
+ # propogate the override for the server-side.
+ # -trace overrides any previous APACHE_TEST_TRACE_LEVEL settings
+ $ENV{APACHE_TEST_TRACE_LEVEL} = $opts{trace};
}
else {
error "unknown trace level: $opts{trace}",
1.14 +1 -0 httpd-test/perl-framework/Apache-Test/lib/Apache/TestRunPerl.pm
Index: TestRunPerl.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRunPerl.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- TestRunPerl.pm 23 Apr 2003 02:24:16 -0000 1.13
+++ TestRunPerl.pm 14 May 2003 01:12:22 -0000 1.14
@@ -27,6 +27,7 @@
$test_config->preamble_register(qw(configure_libmodperl));
$test_config->postamble_register(qw(configure_inc
+ configure_trace
configure_pm_tests_inc
configure_startup_pl
configure_pm_tests));
1.14 +28 -8 httpd-test/perl-framework/Apache-Test/lib/Apache/TestTrace.pm
Index: TestTrace.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestTrace.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- TestTrace.pm 23 Apr 2003 01:58:31 -0000 1.13
+++ TestTrace.pm 14 May 2003 01:12:22 -0000 1.14
@@ -19,7 +19,7 @@
use subs (@Levels, @Utils);
# default settings overrideable by users
-$Level = 'info';
+$Level = undef;
$LogFH = \*STDERR;
# private data
@@ -97,12 +97,21 @@
for my $level (@Levels,@Utils) {
no strict 'refs';
*$level = sub {
- $trace->($level, @_)
- if ( $levels{$Level} || $levels{$default_level} ) >= $levels{$level};
+ $trace->($level, @_) if trace_level() >= $levels{$level};
};
}
}
+sub trace_level {
+ # overriden by user/-trace
+ (defined $Level && $levels{$Level}) ||
+ # or overriden by env var
+ (exists $ENV{APACHE_TEST_TRACE_LEVEL} &&
+ $levels{$ENV{APACHE_TEST_TRACE_LEVEL}}) ||
+ # or default
+ $levels{$default_level};
+}
+
1;
__END__
@@ -113,7 +122,7 @@
=head1 SYNOPSIS
use Apache::TestTrace;
-
+
# test sub that exercises all the tracing functions
sub test {
print $Apache::TestTrace::LogFH
@@ -122,24 +131,24 @@
warning notice info debug todo);
print $Apache::TestTrace::LogFH "\n\n"
};
-
+
# demo the trace subs using default setting
test();
-
+
{
# override the default trace level with 'crit'
local $Apache::TestTrace::Level = 'crit';
# now only 'crit' and higher levels will do tracing lower level
test();
}
-
+
{
# set the trace level to 'debug'
local $Apache::TestTrace::Level = 'debug';
# now only 'debug' and higher levels will do tracing lower level
test();
}
-
+
{
open OUT, ">/tmp/foo" or die $!;
# override the default Log filehandle
@@ -148,6 +157,12 @@
test();
close OUT;
}
+
+ # override tracing level via -trace opt
+ % t/TEST -trace=crit
+
+ # override tracing level via env var
+ % env APACHE_TEST_TRACE_LEVEL=crit t/TEST
=head1 DESCRIPTION
@@ -179,6 +194,11 @@
output. The default setting of this variable is I<warning>. Other
valid values are: I<emerg>, I<alert>, I<crit>, I<error>, I<warning>,
I<notice>, I<info>, I<debug>.
+
+Another way to affect the trace level is to set
+C<$ENV{APACHE_TEST_TRACE_LEVEL}>, which takes effect if
+C<$Apache::TestTrace::Level> is not set. So an explicit setting of
+C<$Apache::TestTrace::Level> always takes precedence.
By default all the output generated by these functions goes to
STDERR. You can override the default filehandler by overriding
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic