my $self = {};
+ if ($LXDebug::watch_form) {
+ require SL::Watchdog;
+ tie %{ $self }, 'SL::Watchdog';
+ }
+
read(STDIN, $_, $ENV{CONTENT_LENGTH});
if ($ENV{QUERY_STRING}) {
my $data_dumper_available;
+our $global_level;
+our $watch_form;
+
BEGIN {
eval("use Data::Dumper");
$data_dumper_available = $@ ? 0 : 1;
$global_level = NONE;
+ $watch_form = 0;
}
sub new {
$self->{"file"} = "/tmp/lx-office-debug.log";
$self->{"target"} = FILE_TARGET;
$self->{"level"} = 0;
- $self->{"watchedvars"} = {};
while ($_[0]) {
$self->{ $_[0] } = $_[1];
my ($self, $level) = @_;
$level *= 1;
- $self->check_watched_form_variables();
-
return 1 unless ($global_level & TRACE); # ignore if traces aren't active
return 1 if $level && !($global_level & $level); # ignore if level of trace isn't active
my ($self, $level) = @_;
$level *= 1;
- $self->check_watched_form_variables();
-
return 1 unless ($global_level & TRACE); # ignore if traces aren't active
return 1 if $level && !($global_level & $level); # ignore if level of trace isn't active
sub message {
my ($self, $level, $message) = @_;
- $self->check_watched_form_variables();
$self->_write(level2string($level), $message) if (($self->{"level"} | $global_level) & $level || !$level);
}
join '/', qw(info debug1 debug2 query trace)[ grep { (reverse split //, sprintf "%05b", $_[0])[$_] } 0..4 ]
}
-sub watch_form_variable {
- my ($self, $var) = @_;
-
- $self->{"watchedvars"}->{$var} = $main::form->{$var};
- $self->_write("WATCH", "Adding \$form->{$var} with current value \"$main::form->{$var}\"");
-}
-
-sub check_watched_form_variables {
- my ($self) = @_;
-
- return unless $main::form;
-
- foreach my $var (sort(keys(%{ $self->{"watchedvars"} }))) {
- if ($main::form->{$var} ne $self->{"watchedvars"}->{$var}) {
- $self->_write("WATCH", "Variable \$form->{$var} changed from \"" .
- $self->{"watchedvars"}->{$var} . "\" to \"" .
- $main::form->{$var} . "\"");
- $self->{"watchedvars"}->{$var} = $main::form->{$var};
- }
- }
-}
-
1;
--- /dev/null
+package SL::Watchdog;
+
+use Data::Dumper;
+
+require Tie::Hash;
+
+@ISA = (Tie::StdHash);
+
+my %watched_variables;
+
+sub STORE {
+ my ($this, $key, $value) = @_;
+
+ if (substr($key, 0, 10) eq "Watchdog::") {
+ substr $key, 0, 10, "";
+ $watched_variables{$key} = $value;
+ if ($value) {
+ $main::lxdebug->_write("WATCH", "Starting to watch '$key' with current value '$this->{$key}'");
+ } else {
+ $main::lxdebug->_write("WATCH", "Stopping to watch '$key'");
+ }
+ return;
+
+ }
+
+ if ($watched_variables{$key}
+ && ($this->{$key} ne $value)) {
+ my $subroutine = (caller 1)[3];
+ my ($self_filename, $self_line) = (caller)[1, 2];
+ $main::lxdebug->_write("WATCH",
+ "Value of '$key' changed from '$this->{$key}' to '$value' "
+ . "in ${subroutine} at ${self_filename}:${self_line}");
+ }
+
+ $this->{$key} = $value;
+}
+
+1;
use Cwd;
-use vars qw($userspath $spool $memberfile $templates $sendmail $language $sid $latex $eur $webdav $lizenzen $jscalendar);
+use vars qw($userspath $spool $memberfile $templates $sendmail $language $sid $latex $eur $webdav $lizenzen $jscalendar $watch_form_variables);
# path to user configuration files
$userspath = "users";
#
# Beipiel:
# $LXDebug::global_level = LXDebug::TRACE | LXDebug::QUERY;
-$LXDebug::global_level = LXDebug::ALL;
+$LXDebug::global_level = LXDebug::NONE;
+
+# Überwachung der Inhalte von $form aktiviert oder nicht? Wenn ja,
+# dann können einzelne Variablen mit
+# $form->{"Watchdog::<variablenname>"} = 1;
+# überwacht werden. Bedeutet aber auch einen Geschwindigkeitsverlust,
+# weshalb sie normalerweise deaktiviert ist.
+$LXDebug::watch_form = 0;
1;