X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FLXDebug.pm;h=6a8ca5af5eee16ecd4ec67f953b72665a1311cf6;hb=44472690fcd26f0c9bd21d7e9d697dbf77c55275;hp=87bfd7f7cb40d0649fc18577a0efe871a1b743b7;hpb=c4c2f760ece99afd4738c28ce17e635a4f24d102;p=kivitendo-erp.git diff --git a/SL/LXDebug.pm b/SL/LXDebug.pm index 87bfd7f7c..6a8ca5af5 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; @@ -151,23 +152,16 @@ sub dump_sql_result { return; } - my %column_lengths; - my $first_row = 1; + my %column_lengths = map { $_, length $_ } keys %{ $results->[0] }; foreach my $row (@{ $results }) { - if ($first_row) { - map { $column_lengths{$_} = length $_ } keys %{ $row }; - $first_row = 0; - } - map { $column_lengths{$_} = length $row->{$_} if (length $row->{$_} > $column_lengths{$_}) } keys %{ $row }; } 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));