Revision e8557567
Von Sven Schöling vor etwa 12 Jahren hinzugefügt
SL/Dispatcher.pm | ||
---|---|---|
my %routing;
|
||
eval { %routing = _route_request($ENV{SCRIPT_NAME}); 1; } or return;
|
||
($routing_type, $script_name, $action) = @routing{qw(type controller action)};
|
||
$::lxdebug->log_request($routing_type, $script_name, $action);
|
||
|
||
$::request->type(lc($routing{request_type} || 'html'));
|
||
|
SL/LXDebug.pm | ||
---|---|---|
use constant TRACE => 1 << 4;
|
||
use constant BACKTRACE_ON_ERROR => 1 << 5;
|
||
use constant REQUEST_TIMER => 1 << 6;
|
||
use constant WARN => 1 << 7;
|
||
use constant TRACE2 => 1 << 8;
|
||
use constant ALL => (1 << 9) - 1;
|
||
use constant REQUEST => 1 << 7;
|
||
use constant WARN => 1 << 8;
|
||
use constant TRACE2 => 1 << 9;
|
||
use constant ALL => (1 << 10) - 1;
|
||
use constant DEVEL => INFO | DEBUG1 | QUERY | TRACE | BACKTRACE_ON_ERROR | REQUEST_TIMER;
|
||
|
||
use constant FILE_TARGET => 0;
|
||
... | ... | |
use POSIX qw(strftime getppid);
|
||
use Time::HiRes qw(gettimeofday tv_interval);
|
||
use YAML;
|
||
use SL::Request ();
|
||
|
||
use strict;
|
||
|
||
... | ... | |
local *FILE;
|
||
|
||
chomp($message);
|
||
$self->_write_raw("${date}${message}\n");
|
||
}
|
||
|
||
sub _write_raw {
|
||
my ($self, $message) = @_;
|
||
local *FILE;
|
||
if ((FILE_TARGET == $self->{"target"})
|
||
&& open(FILE, ">>", $self->{"file"})) {
|
||
print(FILE "${date}${message}\n");
|
||
close(FILE);
|
||
print FILE $message;
|
||
close FILE;
|
||
|
||
} elsif (STDERR_TARGET == $self->{"target"}) {
|
||
print(STDERR "${date}${message}\n");
|
||
print STDERR $message;
|
||
}
|
||
}
|
||
|
||
... | ... | |
return $global_level & $self->_by_name($level);
|
||
}
|
||
|
||
sub is_request_logging_enabled {
|
||
my ($self) = @_;
|
||
return $global_level & REQUEST;
|
||
}
|
||
|
||
sub add_request_params {
|
||
my ($self, $key, $value) = @_;
|
||
return unless $self->is_request_logging_enabled;
|
||
return if $key =~ /password/;
|
||
|
||
push @{ $::request->{debug}{PARAMS} ||= [] }, [ $key => $value ];
|
||
}
|
||
|
||
sub log_request {
|
||
my ($self, $type, $controller, $action) = @_;
|
||
return unless $self->is_request_logging_enabled;
|
||
|
||
my $session_id = $::auth->create_or_refresh_session;
|
||
|
||
my $template = <<EOL;
|
||
*************************************
|
||
GET $ENV{SCRIPT_NAME} $session_id ($::myconfig{login})
|
||
routing: $type, controller: $controller, action: $action
|
||
EOL
|
||
|
||
$self->_write('Request', $template);
|
||
|
||
my $params = join "\n ", map {
|
||
"$_->[0] = $_->[1]"
|
||
} @{ $::request->{debug}{PARAMS} || [] };
|
||
|
||
$self->_write_raw(<<EOL);
|
||
|
||
Params
|
||
$params
|
||
EOL
|
||
}
|
||
|
||
1;
|
||
__END__
|
||
|
SL/Request.pm | ||
---|---|---|
sub _input_to_hash {
|
||
$::lxdebug->enter_sub(2);
|
||
|
||
my ($target, $input) = @_;
|
||
my ($target, $input, $log) = @_;
|
||
my @pairs = split(/&/, $input);
|
||
|
||
foreach (@pairs) {
|
||
my ($key, $value) = split(/=/, $_, 2);
|
||
_store_value($target, uri_decode($key), uri_decode($value)) if ($key);
|
||
next unless $key;
|
||
_store_value($target, uri_decode($key), uri_decode($value));
|
||
|
||
# for debugging
|
||
$::lxdebug->add_request_params(uri_decode($key) => uri_decode($value)) if $log;
|
||
}
|
||
|
||
$::lxdebug->leave_sub(2);
|
||
}
|
||
|
||
sub _parse_multipart_formdata {
|
||
my ($target, $temp_target, $input) = @_;
|
||
my ($target, $temp_target, $input, $log) = @_;
|
||
my ($name, $filename, $headers_done, $content_type, $boundary_found, $need_cr, $previous, $p_attachment, $encoding, $transfer_encoding);
|
||
my $data_start = 0;
|
||
|
||
... | ... | |
} else {
|
||
${ $previous } = $data;
|
||
}
|
||
$::lxdebug->add_request_params($name, $$previous) if $log;
|
||
|
||
undef $previous;
|
||
undef $filename;
|
||
... | ... | |
|
||
# since both of these can potentially bring their encoding in INPUT_ENCODING
|
||
# they get dumped into temp_target
|
||
_input_to_hash($temp_target, $ENV{QUERY_STRING}) if $ENV{QUERY_STRING};
|
||
_input_to_hash($temp_target, $ARGV[0]) if @ARGV && $ARGV[0];
|
||
_input_to_hash($temp_target, $ENV{QUERY_STRING}, 1) if $ENV{QUERY_STRING};
|
||
_input_to_hash($temp_target, $ARGV[0], 1) if @ARGV && $ARGV[0];
|
||
|
||
if ($ENV{CONTENT_LENGTH}) {
|
||
my $content;
|
||
... | ... | |
if ($ENV{'CONTENT_TYPE'} && $ENV{'CONTENT_TYPE'} =~ /multipart\/form-data/) {
|
||
# multipart formdata can bring it's own encoding, so give it both
|
||
# and let ti decide on it's own
|
||
_parse_multipart_formdata($target, $temp_target, $content);
|
||
_parse_multipart_formdata($target, $temp_target, $content, 1);
|
||
} else {
|
||
# normal encoding must be recoded
|
||
_input_to_hash($temp_target, $content);
|
||
_input_to_hash($temp_target, $content, 1);
|
||
}
|
||
}
|
||
|
config/kivitendo.conf.default | ||
---|---|---|
# TRACE - Track function calls and returns
|
||
# BACKTRACE_ON_ERROR - Print a function call backtrace when $form->error() is called
|
||
# REQUEST_TIMER - Log timing of HTTP requests
|
||
# REQUEST - Log each request. Careful! Passwords get filtered, but
|
||
# there may be confidential information being logged here
|
||
# WARN - warnings
|
||
# ALL - all possible debug messages
|
||
#
|
Auch abrufbar als: Unified diff
Neuer Debugparameter: Request
Loggt sinnvolle Informationen zum Request.