Revision e8557567
Von Sven Schöling vor mehr als 11 Jahren hinzugefügt
SL/Dispatcher.pm | ||
---|---|---|
209 | 209 |
my %routing; |
210 | 210 |
eval { %routing = _route_request($ENV{SCRIPT_NAME}); 1; } or return; |
211 | 211 |
($routing_type, $script_name, $action) = @routing{qw(type controller action)}; |
212 |
$::lxdebug->log_request($routing_type, $script_name, $action); |
|
212 | 213 |
|
213 | 214 |
$::request->type(lc($routing{request_type} || 'html')); |
214 | 215 |
|
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 |
|
SL/Request.pm | ||
---|---|---|
70 | 70 |
sub _input_to_hash { |
71 | 71 |
$::lxdebug->enter_sub(2); |
72 | 72 |
|
73 |
my ($target, $input) = @_; |
|
73 |
my ($target, $input, $log) = @_;
|
|
74 | 74 |
my @pairs = split(/&/, $input); |
75 | 75 |
|
76 | 76 |
foreach (@pairs) { |
77 | 77 |
my ($key, $value) = split(/=/, $_, 2); |
78 |
_store_value($target, uri_decode($key), uri_decode($value)) if ($key); |
|
78 |
next unless $key; |
|
79 |
_store_value($target, uri_decode($key), uri_decode($value)); |
|
80 |
|
|
81 |
# for debugging |
|
82 |
$::lxdebug->add_request_params(uri_decode($key) => uri_decode($value)) if $log; |
|
79 | 83 |
} |
80 | 84 |
|
81 | 85 |
$::lxdebug->leave_sub(2); |
82 | 86 |
} |
83 | 87 |
|
84 | 88 |
sub _parse_multipart_formdata { |
85 |
my ($target, $temp_target, $input) = @_; |
|
89 |
my ($target, $temp_target, $input, $log) = @_;
|
|
86 | 90 |
my ($name, $filename, $headers_done, $content_type, $boundary_found, $need_cr, $previous, $p_attachment, $encoding, $transfer_encoding); |
87 | 91 |
my $data_start = 0; |
88 | 92 |
|
... | ... | |
113 | 117 |
} else { |
114 | 118 |
${ $previous } = $data; |
115 | 119 |
} |
120 |
$::lxdebug->add_request_params($name, $$previous) if $log; |
|
116 | 121 |
|
117 | 122 |
undef $previous; |
118 | 123 |
undef $filename; |
... | ... | |
263 | 268 |
|
264 | 269 |
# since both of these can potentially bring their encoding in INPUT_ENCODING |
265 | 270 |
# they get dumped into temp_target |
266 |
_input_to_hash($temp_target, $ENV{QUERY_STRING}) if $ENV{QUERY_STRING}; |
|
267 |
_input_to_hash($temp_target, $ARGV[0]) if @ARGV && $ARGV[0];
|
|
271 |
_input_to_hash($temp_target, $ENV{QUERY_STRING}, 1) if $ENV{QUERY_STRING};
|
|
272 |
_input_to_hash($temp_target, $ARGV[0], 1) if @ARGV && $ARGV[0];
|
|
268 | 273 |
|
269 | 274 |
if ($ENV{CONTENT_LENGTH}) { |
270 | 275 |
my $content; |
... | ... | |
272 | 277 |
if ($ENV{'CONTENT_TYPE'} && $ENV{'CONTENT_TYPE'} =~ /multipart\/form-data/) { |
273 | 278 |
# multipart formdata can bring it's own encoding, so give it both |
274 | 279 |
# and let ti decide on it's own |
275 |
_parse_multipart_formdata($target, $temp_target, $content); |
|
280 |
_parse_multipart_formdata($target, $temp_target, $content, 1);
|
|
276 | 281 |
} else { |
277 | 282 |
# normal encoding must be recoded |
278 |
_input_to_hash($temp_target, $content); |
|
283 |
_input_to_hash($temp_target, $content, 1);
|
|
279 | 284 |
} |
280 | 285 |
} |
281 | 286 |
|
config/kivitendo.conf.default | ||
---|---|---|
260 | 260 |
# TRACE - Track function calls and returns |
261 | 261 |
# BACKTRACE_ON_ERROR - Print a function call backtrace when $form->error() is called |
262 | 262 |
# REQUEST_TIMER - Log timing of HTTP requests |
263 |
# REQUEST - Log each request. Careful! Passwords get filtered, but |
|
264 |
# there may be confidential information being logged here |
|
263 | 265 |
# WARN - warnings |
264 | 266 |
# ALL - all possible debug messages |
265 | 267 |
# |
Auch abrufbar als: Unified diff
Neuer Debugparameter: Request
Loggt sinnvolle Informationen zum Request.