Commit f3de8a0b authored by Dietmar Maurer's avatar Dietmar Maurer

spiceproxy: improve loggin code

 * use the same log file as pveproxy: /var/log/pveproxy/access.log

 * log early just after establishing the connection.
parent 98cbb832
......@@ -61,6 +61,9 @@ sub log_request {
# like apache2 common log format
# LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
return if $loginfo->{written}; # avoid duplicate logs
$loginfo->{written} = 1;
my $peerip = $reqstate->{peer_host} || '-';
my $userid = $loginfo->{userid} || '-';
my $content_length = defined($loginfo->{content_length}) ? $loginfo->{content_length} : '-';
......@@ -556,6 +559,10 @@ sub handle_spice_proxy_request {
my $proto = $reqstate->{proto} ? $reqstate->{proto}->{str} : 'HTTP/1.0';
my $res = "$proto 200 OK\015\012"; # hope this is the right answer?
$reqstate->{hdl}->push_write($res);
# log early
$reqstate->{log}->{code} = 200;
$self->log_request($reqstate);
};
};
if (my $err = $@) {
......
#!/usr/bin/perl -w -T
# Note: In theory, all this can be done by 'pveproxy' daemon. But som API call
# still have blocking code, so we use a separate daemon to avoid that the console
# get blocked.
$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
......@@ -51,7 +55,7 @@ eval {
lockfile => $lockfile,
debug => $opt_debug,
spiceproxy => 1,
logfile => '/var/log/pveproxy/spice.log',
logfile => '/var/log/pveproxy/access.log',
);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment