Permalink
Browse files

bug: order of init args processing (level_flag_paths and name must be…

… before level, for correct level setting using level flag file)
  • Loading branch information...
1 parent aff0fef commit 5c995062f53c3df8c1fa008f1a21e555a0ff10a5 Steven Haryanto (on PC) committed Jul 14, 2011
Showing with 13 additions and 12 deletions.
  1. +12 −10 lib/Log/Any/App.pm
  2. +1 −2 t/01-basics.t
View
@@ -292,6 +292,7 @@ sub _parse_args {
sub _parse_opts {
my ($args, $caller) = @_;
$args //= []; # if we don't import(), we never get args
+ _debug("parse_opts: args = [".join(", ", @$args)."]");
my $spec = {
name => _basename($0),
@@ -314,6 +315,16 @@ sub _parse_opts {
$i++;
}
+ if (defined $opts{name}) {
+ $spec->{name} = $opts{name};
+ delete $opts{name};
+ }
+
+ if (defined $opts{level_flag_paths}) {
+ $spec->{level_flag_paths} = $opts{level_flag_paths};
+ delete $opts{level_flag_paths};
+ }
+
$spec->{level} = _set_level("", "", $spec);
if (!$spec->{level} && defined($opts{level})) {
$spec->{level} = _check_level($opts{level}, "-level");
@@ -347,16 +358,6 @@ sub _parse_opts {
delete $opts{init};
}
- if (defined $opts{name}) {
- $spec->{name} = $opts{name};
- delete $opts{name};
- }
-
- if (defined $opts{level_flag_paths}) {
- $spec->{level_flag_paths} = $opts{level_flag_paths};
- delete $opts{level_flag_paths};
- }
-
if (defined $opts{daemon}) {
$spec->{daemon} = $opts{daemon};
$is_daemon = $opts{daemon};
@@ -650,6 +651,7 @@ sub _check_level {
sub _set_level {
my ($prefix, $which, $spec) = @_;
+ #use Data::Dumper; print Dumper $spec;
my $p_ = $prefix ? "${prefix}_" : "";
my $P_ = $prefix ? uc("${prefix}_") : "";
my $F_ = $prefix ? ucfirst("${prefix}_") : "";
View
@@ -131,7 +131,7 @@ while (my ($k, $v) = each %vars) {
my @lfftests = (
{ext => "DEBUG", level => "debug"},
{ext => "FILE_VERBOSE", level => "warn", file_level => "info"},
- {ext => "log_level", content => "quiet", level => "error"},
+ {ext => "log_level", content => "error", level => "error"},
{ext => "SCREEN_log_level", content => "trace", level => "warn",
screen_level => "trace"},
);
@@ -148,7 +148,6 @@ for my $test (@lfftests) {
$args{$_} = $test->{$_} for grep {/_level$/} keys %$test;
test_init(%args);
unlink $flag_file or die "Can't unlink flag file $flag_file: $!";
- exit;
}
#chdir "/" if Test::More->builder->is_passing;

0 comments on commit 5c99506

Please sign in to comment.