Revision e8557567
Von Sven Schöling vor mehr als 11 Jahren hinzugefügt
SL/LXDebug.pm | ||
---|---|---|
8 | 8 |
use constant TRACE => 1 << 4; |
9 | 9 |
use constant BACKTRACE_ON_ERROR => 1 << 5; |
10 | 10 |
use constant REQUEST_TIMER => 1 << 6; |
11 |
use constant WARN => 1 << 7; |
|
12 |
use constant TRACE2 => 1 << 8; |
|
13 |
use constant ALL => (1 << 9) - 1; |
|
11 |
use constant REQUEST => 1 << 7; |
|
12 |
use constant WARN => 1 << 8; |
|
13 |
use constant TRACE2 => 1 << 9; |
|
14 |
use constant ALL => (1 << 10) - 1; |
|
14 | 15 |
use constant DEVEL => INFO | DEBUG1 | QUERY | TRACE | BACKTRACE_ON_ERROR | REQUEST_TIMER; |
15 | 16 |
|
16 | 17 |
use constant FILE_TARGET => 0; |
... | ... | |
20 | 21 |
use POSIX qw(strftime getppid); |
21 | 22 |
use Time::HiRes qw(gettimeofday tv_interval); |
22 | 23 |
use YAML; |
24 |
use SL::Request (); |
|
23 | 25 |
|
24 | 26 |
use strict; |
25 | 27 |
|
... | ... | |
251 | 253 |
local *FILE; |
252 | 254 |
|
253 | 255 |
chomp($message); |
256 |
$self->_write_raw("${date}${message}\n"); |
|
257 |
} |
|
254 | 258 |
|
259 |
sub _write_raw { |
|
260 |
my ($self, $message) = @_; |
|
261 |
local *FILE; |
|
255 | 262 |
if ((FILE_TARGET == $self->{"target"}) |
256 | 263 |
&& open(FILE, ">>", $self->{"file"})) { |
257 |
print(FILE "${date}${message}\n");
|
|
258 |
close(FILE);
|
|
264 |
print FILE $message;
|
|
265 |
close FILE;
|
|
259 | 266 |
|
260 | 267 |
} elsif (STDERR_TARGET == $self->{"target"}) { |
261 |
print(STDERR "${date}${message}\n");
|
|
268 |
print STDERR $message;
|
|
262 | 269 |
} |
263 | 270 |
} |
264 | 271 |
|
... | ... | |
322 | 329 |
return $global_level & $self->_by_name($level); |
323 | 330 |
} |
324 | 331 |
|
332 |
sub is_request_logging_enabled { |
|
333 |
my ($self) = @_; |
|
334 |
return $global_level & REQUEST; |
|
335 |
} |
|
336 |
|
|
337 |
sub add_request_params { |
|
338 |
my ($self, $key, $value) = @_; |
|
339 |
return unless $self->is_request_logging_enabled; |
|
340 |
return if $key =~ /password/; |
|
341 |
|
|
342 |
push @{ $::request->{debug}{PARAMS} ||= [] }, [ $key => $value ]; |
|
343 |
} |
|
344 |
|
|
345 |
sub log_request { |
|
346 |
my ($self, $type, $controller, $action) = @_; |
|
347 |
return unless $self->is_request_logging_enabled; |
|
348 |
|
|
349 |
my $session_id = $::auth->create_or_refresh_session; |
|
350 |
|
|
351 |
my $template = <<EOL; |
|
352 |
************************************* |
|
353 |
GET $ENV{SCRIPT_NAME} $session_id ($::myconfig{login}) |
|
354 |
routing: $type, controller: $controller, action: $action |
|
355 |
EOL |
|
356 |
|
|
357 |
$self->_write('Request', $template); |
|
358 |
|
|
359 |
my $params = join "\n ", map { |
|
360 |
"$_->[0] = $_->[1]" |
|
361 |
} @{ $::request->{debug}{PARAMS} || [] }; |
|
362 |
|
|
363 |
$self->_write_raw(<<EOL); |
|
364 |
|
|
365 |
Params |
|
366 |
$params |
|
367 |
EOL |
|
368 |
} |
|
369 |
|
|
325 | 370 |
1; |
326 | 371 |
__END__ |
327 | 372 |
|
Auch abrufbar als: Unified diff
Neuer Debugparameter: Request
Loggt sinnvolle Informationen zum Request.