From 860a3098ea9dd3e306ab7b393d6adbcbe2270d5d Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Tue, 30 Mar 2010 10:43:22 +1300 Subject: [PATCH] Add some statistical logging for script/database execution times. --- inc/CalDAVRequest.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index f6681848..b373689c 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -1141,11 +1141,18 @@ EOSQL; header( "Content-Length: ".strlen($message) ); echo $message; - if ( strlen($message) > 100 || strstr($message, "\n") ) { - $message = substr( preg_replace("#\s+#m", ' ', $message ), 0, 100) . (strlen($message) > 100 ? "..." : ""); - } + if ( isset($c->dbg['caldav']) && $c->dbg['caldav'] ) { + if ( strlen($message) > 100 || strstr($message, "\n") ) { + $message = substr( preg_replace("#\s+#m", ' ', $message ), 0, 100) . (strlen($message) > 100 ? "..." : ""); + } - dbg_error_log("caldav", "Status: %d, Message: %s, User: %d, Path: %s", $status, $message, $session->user_no, $this->path); + dbg_error_log("caldav", "Status: %d, Message: %s, User: %d, Path: %s", $status, $message, $session->user_no, $this->path); + } + if ( isset($c->dbg['statistics']) && $c->dbg['statistics'] ) { + $script_time = microtime(true) - $c->script_start_time; + @dbg_error_log("statistics", "Method: %s, Status: %d, Script: %5.3lfs, Queries: %5.3lfs, URL: %s", + $this->method, $status, $script_time, $c->total_query_time, $this->path); + } exit(0); }