X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FLXDebug.pm;h=047d2b0b611e6000442fb9192f355c263fd8cb84;hb=389007ac0512ed52a2a9bf1bf46f680b5fbb7f57;hp=684a1e7e3036450532a501c8d29a1dfa11bd0e72;hpb=54272ac3b2d1695a9a49acc8fbc681657480f966;p=kivitendo-erp.git diff --git a/SL/LXDebug.pm b/SL/LXDebug.pm index 684a1e7e3..047d2b0b6 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; @@ -103,9 +104,9 @@ sub leave_sub { } sub show_backtrace { - my ($self) = @_; + my ($self, $force) = @_; - return 1 unless ($global_level & BACKTRACE_ON_ERROR); + return 1 unless ($force || ($global_level & BACKTRACE_ON_ERROR)); $self->message(BACKTRACE_ON_ERROR, "Starting full caller dump:"); my $level = 0; @@ -127,9 +128,25 @@ sub dump { my ($self, $level, $name, $variable) = @_; 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); $self->message($level, "dumping ${name}:\n" . $dumper->Dump()); + + $variable->{password} = $password if (defined $password); + + # 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 }; + } + } else { $self->message($level, "dumping ${name}: Data::Dumper not available; "