X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/87e65e6c1cc64bfb2d73b6914ed2ef136861dd42..87eebe6:/SL/LXDebug.pm diff --git a/SL/LXDebug.pm b/SL/LXDebug.pm index e4e0cb272..13f86a71a 100644 --- a/SL/LXDebug.pm +++ b/SL/LXDebug.pm @@ -16,26 +16,19 @@ use constant DEVEL => INFO | DEBUG1 | QUERY | TRACE | BACKTRACE_ON_ use constant FILE_TARGET => 0; use constant STDERR_TARGET => 1; +use Data::Dumper; use POSIX qw(strftime getppid); use Time::HiRes qw(gettimeofday tv_interval); use YAML; use strict; -my ($data_dumper_available, $text_diff_available); +my ($text_diff_available); -our $global_level; -our $watch_form; +our $global_level = NONE(); +our $watch_form = 0; our $file_name; -BEGIN { - eval("use Data::Dumper"); - $data_dumper_available = $@ ? 0 : 1; - - $global_level = NONE; - $watch_form = 0; -} - sub new { my $type = shift; my $self = {}; @@ -159,33 +152,29 @@ sub warn { sub dump { my ($self, $level, $name, $variable, %options) = @_; - if ($data_dumper_available) { - my $password; - if ($variable && ('Form' eq ref $variable) && defined $variable->{password}) { - $password = $variable->{password}; - $variable->{password} = 'X' x 8; - } - - my $dumper = Data::Dumper->new([$variable]); - $dumper->Sortkeys(1); - $dumper->Indent(2); - $dumper->$_($options{$_}) for keys %options; - $self->message($level, "dumping ${name}:\n" . $dumper->Dump()); + my $password; + if ($variable && ('Form' eq ref $variable) && defined $variable->{password}) { + $password = $variable->{password}; + $variable->{password} = 'X' x 8; + } - $variable->{password} = $password if (defined $password); + my $dumper = Data::Dumper->new([$variable]); + $dumper->Sortkeys(1); + $dumper->Indent(2); + $dumper->$_($options{$_}) for keys %options; + my $output = $dumper->Dump(); + $self->message($level, "dumping ${name}:\n" . $output); - # 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) || ('Form' eq ref $variable))) { - keys %{ $variable }; - } + $variable->{password} = $password if (defined $password); - } else { - $self->message($level, - "dumping ${name}: Data::Dumper not available; " - . "variable cannot be dumped"); + # 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) || ('Form' eq ref $variable))) { + keys %{ $variable }; } + + return $output; } sub dump_yaml {