X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=SL%2FLXDebug.pm;h=185297ba0817a6e5fadcab75e9829d1f491db59c;hb=6216f7b53a81a73641a2d98ea43f363b6a615b07;hp=d902e2ab2d3965fc91aa1b246883f05369dfcf99;hpb=6e00b261a86eaa1ba0bc9da62bd2f42f94e1bac8;p=kivitendo-erp.git diff --git a/SL/LXDebug.pm b/SL/LXDebug.pm index d902e2ab2..185297ba0 100644 --- a/SL/LXDebug.pm +++ b/SL/LXDebug.pm @@ -1,13 +1,14 @@ package LXDebug; -use constant NONE => 0; -use constant INFO => 1; -use constant DEBUG1 => 2; -use constant DEBUG2 => 4; -use constant QUERY => 8; -use constant TRACE => 16; -use constant BACKTRACE_ON_ERROR => 32; -use constant ALL => 63; +use constant NONE => 0; +use constant INFO => 1; +use constant DEBUG1 => 1 << 1; +use constant DEBUG2 => 1 << 2; +use constant QUERY => 1 << 3; +use constant TRACE => 1 << 4; +use constant BACKTRACE_ON_ERROR => 1 << 5; +use constant ALL => (1 << 6) - 1; +use constant DEVEL => INFO | QUERY | TRACE | BACKTRACE_ON_ERROR; use constant FILE_TARGET => 0; use constant STDERR_TARGET => 1; @@ -130,6 +131,14 @@ sub dump { my $dumper = Data::Dumper->new([$variable]); $dumper->Sortkeys(1); $self->message($level, "dumping ${name}:\n" . $dumper->Dump()); + + # Data::Dumper does not reset the iterator belonging to this hash + # if 'Sortkeys' is true. Therefore clear the iterator manually. + # See "perldoc -f each". + if ($variable && ('HASH' eq ref $variable)) { + keys %{ $variable }; + } + } else { $self->message($level, "dumping ${name}: Data::Dumper not available; " @@ -160,8 +169,7 @@ sub dump_sql_result { my @sorted_names = sort keys %column_lengths; my $format = join '|', map { '%' . $column_lengths{$_} . 's' } @sorted_names; - $prefix =~ s|\s*$||; - $prefix .= ' ' if $prefix; + $prefix .= ' ' if $prefix; $self->message($level, $prefix . sprintf($format, @sorted_names)); $self->message($level, $prefix . join('+', map { '-' x $column_lengths{$_} } @sorted_names));