]> wagnertech.de Git - mfinanz.git/blobdiff - SL/LXDebug.pm
Konflikt zwischen zwei Upgrade-Scripten beheben
[mfinanz.git] / SL / LXDebug.pm
index 2f80caccda5fd4e76d6349d851052d19c6fc9034..13f86a71ab1f4df7fc6ea8ae63bda2f85696ac49 100644 (file)
@@ -16,26 +16,19 @@ use constant DEVEL              => INFO | DEBUG1 | QUERY | TRACE | BACKTRACE_ON_
 use constant FILE_TARGET   => 0;
 use constant STDERR_TARGET => 1;
 
 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;
 
 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;
 
 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 = {};
 sub new {
   my $type = shift;
   my $self = {};
@@ -119,7 +112,7 @@ sub leave_sub {
   my ($dummy1, $self_filename, $self_line) = caller(0);
 
   my $indent = " " x --$self->{"calldepth"};
   my ($dummy1, $self_filename, $self_line) = caller(0);
 
   my $indent = " " x --$self->{"calldepth"};
-  my $time = $self->want_request_timer ? $self->get_request_time : '';
+  my $time = $self->want_request_timer ? $self->get_request_time || '' : '';
 
   if (!defined($package)) {
     $self->_write('sub' . $level, $indent . "/ $time top-level?\n");
 
   if (!defined($package)) {
     $self->_write('sub' . $level, $indent . "/ $time top-level?\n");
@@ -157,33 +150,31 @@ sub warn {
 }
 
 sub dump {
 }
 
 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 ($self, $level, $name, $variable, %options) = @_;
 
 
-    my $dumper = Data::Dumper->new([$variable]);
-    $dumper->Sortkeys(1);
-    $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 {
 }
 
 sub dump_yaml {
@@ -340,11 +331,11 @@ __END__
 
 =head1 NAME
 
 
 =head1 NAME
 
-LXDebug - Lx-Office debugging facilities
+LXDebug - kivitendo debugging facilities
 
 =head1 SYNOPSIS
 
 
 =head1 SYNOPSIS
 
-This module provides functions for debugging Lx-Office. An instance is
+This module provides functions for debugging kivitendo. An instance is
 always created as the global variable C<$::lxdebug> at the earliest
 possible moment.
 
 always created as the global variable C<$::lxdebug> at the earliest
 possible moment.
 
@@ -418,7 +409,7 @@ Shortcut for C<INFO | QUERY | TRACE | BACKTRACE_ON_ERROR | REQUEST_TIMER>.
 =head1 CONFIGURATION
 
 C<SL::LXDebug> gets its configuration from the C<[debug]> section of
 =head1 CONFIGURATION
 
 C<SL::LXDebug> gets its configuration from the C<[debug]> section of
-the C<config/lx_office.conf> configuration file. The available options
+the C<config/kivitendo.conf> configuration file. The available options
 are:
 
 =over 4
 are:
 
 =over 4
@@ -453,32 +444,6 @@ following would not trigger a change:
   # This does trigger:
   $::form->{some_hash} = { something => 'else' };
 
   # This does trigger:
   $::form->{some_hash} = { something => 'else' };
 
-=item C<show_debug_menu>
-
-A boolean (C<1> or C<0>). If turned on then certain debug facilities
-are available from the v1 menu. These include e.g.
-
-=over 6
-
-=item *
-
-restarting the FastCGI process by forcefully exiting after the
-request,
-
-=item *
-
-enabling and disabling function tracing,
-
-=item *
-
-enabling and disabling certain debug levels.
-
-=back
-
-Note that these are only useful if Lx-Office is running as a FastCGI
-application because otherwise the changes would be lost when the
-process exits in a normal CGI environment.
-
 =item C<keep_temp_files>
 
 A boolean (C<1> or C<0>). If turned on then certain temporary files
 =item C<keep_temp_files>
 
 A boolean (C<1> or C<0>). If turned on then certain temporary files