forked from extern/egroupware
* CalDAV/CardDAV/GroupDAV new user preference to log requests and responses to Apache error-log
This commit is contained in:
parent
68dd900091
commit
2effc93ea4
@ -44,4 +44,4 @@ $headertime = microtime(true);
|
||||
|
||||
$groupdav = new groupdav();
|
||||
$groupdav->ServeRequest();
|
||||
error_log(sprintf('GroupDAV %s request: status "%s", took %5.3f s'.($headertime?' (header include took %5.3f s)':''),$_SERVER['REQUEST_METHOD'].($_SERVER['REQUEST_METHOD']=='REPORT'?' '.$groupdav->propfind_options['root']['name']:'').' '.$_SERVER['PATH_INFO'],$groupdav->_http_status,microtime(true)-$starttime,$headertime-$starttime));
|
||||
//error_log(sprintf('GroupDAV %s: status "%s", took %5.3f s'.($headertime?' (header include took %5.3f s)':''),$_SERVER['REQUEST_METHOD'].($_SERVER['REQUEST_METHOD']=='REPORT'?' '.$groupdav->propfind_options['root']['name']:'').' '.$_SERVER['PATH_INFO'],$groupdav->_http_status,microtime(true)-$starttime,$headertime-$starttime));
|
||||
|
@ -351,7 +351,7 @@ class groupdav extends HTTP_WebDAV_Server
|
||||
{
|
||||
// principals collection
|
||||
$files['files'][] = $this->add_collection('/principals/', array(
|
||||
'displayname' => lang('Accounts'),
|
||||
'displayname' => lang('Accounts'),
|
||||
));
|
||||
// todo: account_selection owngroups and none!!!
|
||||
foreach($this->accounts->search(array('type' => 'both')) as $account)
|
||||
@ -1235,7 +1235,7 @@ class groupdav extends HTTP_WebDAV_Server
|
||||
}
|
||||
if ($path[0] == '/')
|
||||
{
|
||||
$path = substr($path, 1);
|
||||
$path = substr($path, 1);
|
||||
}
|
||||
$parts = explode('/', $this->_unslashify($path));
|
||||
|
||||
@ -1293,4 +1293,43 @@ class groupdav extends HTTP_WebDAV_Server
|
||||
self::mkprop('write-content',''),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve WebDAV HTTP request
|
||||
*
|
||||
* Reimplemented to add logging, currently only to Apache error-log
|
||||
*/
|
||||
function ServeRequest()
|
||||
{
|
||||
if (($debug_level=$GLOBALS['egw_info']['user']['preferences']['groupdav']['debug_level']) === 'r' ||
|
||||
$debug_level === 'f' || $this->debug)
|
||||
{
|
||||
$starttime = microtime(true);
|
||||
$this->store_request = true;
|
||||
ob_start();
|
||||
}
|
||||
parent::ServeRequest();
|
||||
|
||||
if ($starttime)
|
||||
{
|
||||
error_log($_SERVER['REQUEST_METHOD'].' '.$_SERVER['PATH_INFO'].' HTTP/1.1');
|
||||
// reconstruct headers
|
||||
foreach($_SERVER as $name => $value)
|
||||
{
|
||||
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 ($this->request)
|
||||
{
|
||||
error_log('');
|
||||
foreach(explode("\n",$this->request) as $line) error_log($line);
|
||||
}
|
||||
error_log('HTTP/1.1 '.$this->_http_status);
|
||||
foreach(headers_list() as $line) error_log($line);
|
||||
if (($content = ob_get_flush())) error_log('');
|
||||
if (strlen($content) > 1024 && $debug_level !== 'f') $content = substr($content,0,1024)."\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";
|
||||
foreach(explode("\n",$content) as $line) error_log($line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -120,10 +120,12 @@ class groupdav_hooks
|
||||
'name' => 'debug_level',
|
||||
'help' => 'Enables debug-messages to Apache/PHP error-log, allowing to diagnose problems on a per user basis.',
|
||||
'values' => array(
|
||||
'0' => '0 - off',
|
||||
'1' => '1 - function calls',
|
||||
'2' => '2 - more info',
|
||||
'3' => '3 - complete $_SERVER array',
|
||||
'0' => 'Off',
|
||||
'r' => 'Requests and truncated responses',
|
||||
'f' => 'Requests and full responses',
|
||||
'1' => 'Debug 1 - function calls',
|
||||
'2' => 'Debug 2 - more info',
|
||||
'3' => 'Debug 3 - complete $_SERVER array',
|
||||
),
|
||||
'xmlrpc' => true,
|
||||
'admin' => false,
|
||||
|
Loading…
Reference in New Issue
Block a user