Revision 42985d5f
Von Moritz Bunkus vor fast 4 Jahren hinzugefügt
SL/LXDebug.pm | ||
---|---|---|
19 | 19 |
use constant STDERR_TARGET => 1; |
20 | 20 |
|
21 | 21 |
use Data::Dumper; |
22 |
use List::MoreUtils qw(all); |
|
22 | 23 |
use POSIX qw(strftime getpid); |
23 |
use Scalar::Util qw(blessed refaddr weaken); |
|
24 |
use Scalar::Util qw(blessed refaddr weaken looks_like_number);
|
|
24 | 25 |
use Time::HiRes qw(gettimeofday tv_interval); |
25 | 26 |
use SL::Request (); |
26 | 27 |
use SL::YAML; |
... | ... | |
231 | 232 |
map { $column_lengths{$_} = length $row->{$_} if (length $row->{$_} > $column_lengths{$_}) } keys %{ $row }; |
232 | 233 |
} |
233 | 234 |
|
235 |
my %alignment; |
|
236 |
foreach my $column (keys %column_lengths) { |
|
237 |
my $all_look_like_number = all { (($_->{$column} // '') eq '') || looks_like_number($_->{$column}) } @{ $results }; |
|
238 |
$alignment{$column} = $all_look_like_number ? '' : '-'; |
|
239 |
} |
|
240 |
|
|
234 | 241 |
my @sorted_names = sort keys %column_lengths; |
235 |
my $format = join '|', map { '%' . $column_lengths{$_} . 's' } @sorted_names; |
|
242 |
my $format = join '|', map { '%' . $alignment{$_} . $column_lengths{$_} . 's' } @sorted_names;
|
|
236 | 243 |
|
237 | 244 |
$prefix .= ' ' if $prefix; |
238 | 245 |
|
Auch abrufbar als: Unified diff
LXDebug dump_sql_result: Spaltenanordnung je nach Inhalt
Spalten, die komplett numerisch sind, werden rechtsbündig angeordnet;
alle anderen linksbündig.