missed merge of r37352: log full requests to files directory "$files/groupdav/$user-$agent.log"

log REQUEST_URI not PATH_INFO, to log the correct request
This commit is contained in:
Ralf Becker 2012-01-20 07:45:56 +00:00
parent a9a852d78e
commit 602fcc8121
2 changed files with 31 additions and 10 deletions

View File

@ -1027,24 +1027,45 @@ class groupdav extends HTTP_WebDAV_Server
if ($starttime) if ($starttime)
{ {
error_log($_SERVER['REQUEST_METHOD'].' '.$_SERVER['PATH_INFO'].' HTTP/1.1'); $msg_type = 0;
if ($debug_level === 'f')
{
$msg_type = 3;
$msg_file = $GLOBALS['egw_info']['server']['files_dir'];
$msg_file .= '/groupdav';
$msg_nl = "\n"; // error_log to file does NOT contain new-lines
if (!file_exists($msg_file) && !mkdir($msg_file,0700))
{
error_log(__METHOD__."() Could NOT create directory '$msg_file'!");
return;
}
$msg_file .= '/'.$GLOBALS['egw_info']['user']['account_lid'].'-'.
str_replace('/','!',$_SERVER['HTTP_USER_AGENT']).'.log';
error_log('*** '.$_SERVER['REMOTE_ADDR'].' '.date('c').$msg_nl,$msg_type,$msg_file);
}
error_log($_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI'].' HTTP/1.1'.$msg_nl,$msg_type,$msg_file);
// reconstruct headers // reconstruct headers
foreach($_SERVER as $name => $value) foreach($_SERVER as $name => $value)
{ {
list($type,$name) = explode('_',$name,2); list($type,$name) = explode('_',$name,2);
if ($type == 'HTTP' || $type == 'CONTENT') error_log(str_replace(' ','-',ucwords(strtolower(($type=='HTTP'?'':$type.' ').str_replace('_',' ',$name)))).': '.$value); if ($type == 'HTTP' || $type == 'CONTENT')
{
error_log(str_replace(' ','-',ucwords(strtolower(($type=='HTTP'?'':$type.' ').str_replace('_',' ',$name)))).
': '.($name=='AUTHORIZATION'?'Basic ***************':$value).$msg_nl,$msg_type,$msg_file);
}
} }
if ($this->request) if ($this->request)
{ {
error_log(''); error_log(''.$msg_nl,$msg_type,$msg_file);
foreach(explode("\n",$this->request) as $line) error_log($line); foreach(explode("\n",$this->request) as $line) error_log($line.$msg_nl,$msg_type,$msg_file);
} }
error_log('HTTP/1.1 '.$this->_http_status); error_log('HTTP/1.1 '.$this->_http_status.$msg_nl,$msg_type,$msg_file);
foreach(headers_list() as $line) error_log($line); foreach(headers_list() as $line) error_log($line.$msg_nl,$msg_type,$msg_file);
if (($content = ob_get_flush())) error_log(''); if (($content = ob_get_flush())) error_log(''.$msg_nl,$msg_type,$msg_file);
if (strlen($content) > 1024 && $debug_level !== 'f') $content = substr($content,0,1024)."\n*** LOG TRUNKATED "; if ($debug_level !== 'f' && strlen($content) > 1536) $content = substr($content,0,1536)."\n*** LOG TRUNKATED ";
$content .= sprintf('*** %s --> "%s" took %5.3f s',$_SERVER['REQUEST_METHOD'].($_SERVER['REQUEST_METHOD']=='REPORT'?' '.$this->propfind_options['root']['name']:'').' '.$_SERVER['PATH_INFO'],$this->_http_status,microtime(true)-$starttime)."\n"; $content .= sprintf('*** %s --> "%s" took %5.3f s',$_SERVER['REQUEST_METHOD'].($_SERVER['REQUEST_METHOD']=='REPORT'?' '.$this->propfind_options['root']['name']:'').' '.$_SERVER['PATH_INFO'],$this->_http_status,microtime(true)-$starttime)."\n";
foreach(explode("\n",$content) as $line) error_log($line); foreach(explode("\n",$content) as $line) error_log($line.$msg_nl,$msg_type,$msg_file);
} }
} }
} }

View File

@ -101,7 +101,7 @@ class groupdav_hooks
'values' => array( 'values' => array(
'0' => 'Off', '0' => 'Off',
'r' => 'Requests and truncated responses', 'r' => 'Requests and truncated responses',
'f' => 'Requests and full responses', 'f' => 'Requests and full responses to files directory',
'1' => 'Debug 1 - function calls', '1' => 'Debug 1 - function calls',
'2' => 'Debug 2 - more info', '2' => 'Debug 2 - more info',
'3' => 'Debug 3 - complete $_SERVER array', '3' => 'Debug 3 - complete $_SERVER array',