Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 20a08305

Von Moritz Bunkus vor fast 18 Jahren hinzugefügt

  • ID 20a083051185f1ec54d8a1b40bd64744dacc8790
  • Vorgänger da10bf75
  • Nachfolger 9caaa245

Rudimentäre Überwachungsfunktion für $form-Variablen in LXDebug implementiert.

Unterschiede anzeigen:

SL/LXDebug.pm
30 30
  $self->{"file"}       = "/tmp/lx-office-debug.log";
31 31
  $self->{"target"}     = FILE_TARGET;
32 32
  $self->{"level"}      = 0;
33
  $self->{"watchedvars"} = {};
33 34

  
34 35
  while ($_[0]) {
35 36
    $self->{ $_[0] } = $_[1];
......
56 57
  my ($self, $level) = @_;
57 58
  $level *= 1;
58 59

  
60
  check_watched_form_variables();
61

  
59 62
  return 1 unless ($global_level & TRACE);          # ignore if traces aren't active
60 63
  return 1 if $level && !($global_level & $level);  # ignore if level of trace isn't active
61 64

  
......
79 82
  my ($self, $level) = @_;
80 83
  $level *= 1;
81 84

  
85
  $self->check_watched_form_variables();
86

  
82 87
  return 1 unless ($global_level & TRACE);           # ignore if traces aren't active
83 88
  return 1 if $level && !($global_level & $level);   # ignore if level of trace isn't active
84 89

  
......
134 139
    print(FILE "${date}${message}\n");
135 140
    close(FILE);
136 141

  
137
      } elsif (STDERR_TARGET == $self->{"target"}) {
142
  } elsif (STDERR_TARGET == $self->{"target"}) {
138 143
    print(STDERR "${date}${message}\n");
139 144
  }
140 145
}
......
144 149
  join '/', qw(info debug1 debug2 query trace)[ grep { (reverse split //, sprintf "%05b", $_[0])[$_] } 0..4 ]
145 150
}
146 151

  
152
sub watch_form_variable {
153
  my ($self, $var) = @_;
154

  
155
  $self->{"watchedvars"}->{$var} = $main::form->{$var};
156
  $self->_write("WATCH", "Adding \$form->{$var} with current value \"$main::form->{$var}\"");
157
}
158

  
159
sub check_watched_form_variables {
160
  my ($self) = @_;
161

  
162
  return unless $main::form;
163

  
164
  foreach my $var (sort(keys(%{ $self->{"watchedvars"} }))) {
165
    if ($main::form->{$var} ne $self->{"watchedvars"}->{$var}) {
166
      $self->_write("WATCH", "Variable \$form->{$var} changed from \"" .
167
                    $self->{"watchedvars"}->{$var} . "\" to \"" .
168
                    $main::form->{$var} . "\"");
169
      $self->{"watchedvars"}->{$var} = $main::form->{$var};
170
    }
171
  }
172
}
173

  
147 174
1;

Auch abrufbar als: Unified diff