Revision c92dddcb
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/LXDebug.pm | ||
---|---|---|
21 | 21 |
|
22 | 22 |
use strict; |
23 | 23 |
|
24 |
my $data_dumper_available;
|
|
24 |
my ($data_dumper_available, $text_diff_available);
|
|
25 | 25 |
|
26 | 26 |
our $global_level; |
27 | 27 |
our $watch_form; |
... | ... | |
219 | 219 |
$self->message($level, $prefix . sprintf('(%d row%s)', scalar @{ $results }, scalar @{ $results } > 1 ? 's' : '')); |
220 | 220 |
} |
221 | 221 |
|
222 |
sub show_diff { |
|
223 |
my ($self, $level, $item1, $item2, %params) = @_; |
|
224 |
|
|
225 |
if (!$self->_load_text_diff) { |
|
226 |
$self->warn("Perl module Text::Diff is not available"); |
|
227 |
return; |
|
228 |
} |
|
229 |
|
|
230 |
my @texts = map { ref $_ ? YAML::Dump($_) : $_ } ($item1, $item2); |
|
231 |
|
|
232 |
$self->message($level, Text::Diff::diff(\$texts[0], \$texts[1], \%params)); |
|
233 |
} |
|
234 |
|
|
235 |
sub _load_text_diff { |
|
236 |
$text_diff_available = eval("use Text::Diff (); 1;") ? 1 : 0 unless defined $text_diff_available; |
|
237 |
return $text_diff_available; |
|
238 |
} |
|
239 |
|
|
222 | 240 |
sub enable_sub_tracing { |
223 | 241 |
my ($self) = @_; |
224 | 242 |
$global_level |= TRACE; |
Auch abrufbar als: Unified diff
Funktion für unified diff zweier Objekte/Strings in Debugausgabe