Commit 80c61fc1 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #33 in ZP/z-push from...

Merge pull request #33 in ZP/z-push from feature/ZP-671-log-memory-and-time-details-on-end to develop

* commit 'aac92fc7':
  ZP-671 Changes recommended by Manfred. Released under the Affero GNU General Public License (AGPL) version 3.
  ZP-671 Log memory and time info. Released under the Affero GNU General Public License (AGPL) version 3.
parents 1960cc6c aac92fc7
...@@ -300,5 +300,5 @@ include_once('version.php'); ...@@ -300,5 +300,5 @@ include_once('version.php');
ZPush::GetDeviceManager()->Save(); ZPush::GetDeviceManager()->Save();
// end gracefully // end gracefully
ZLog::Write(LOGLEVEL_DEBUG, '-------- End'); ZLog::WriteEnd();
?> ?>
\ No newline at end of file
...@@ -172,6 +172,27 @@ class ZLog { ...@@ -172,6 +172,27 @@ class ZLog {
return (isset(self::$lastLogs[$loglevel]))?self::$lastLogs[$loglevel]:false; return (isset(self::$lastLogs[$loglevel]))?self::$lastLogs[$loglevel]:false;
} }
/**
* Writes info at the end of the request but only if the LOGLEVEL is DEBUG or more verbose
*
* @access public
* @return
*/
static public function WriteEnd() {
if (LOGLEVEL_DEBUG <= LOGLEVEL) {
if (version_compare(phpversion(), '5.4.0') < 0) {
$time_used = number_format(time() - $_SERVER["REQUEST_TIME"], 4);
}
else {
$time_used = number_format(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 4);
}
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Memory usage information: %s/%s - Execution time: %s - HTTP responde code: %s", memory_get_peak_usage(false), memory_get_peak_usage(true), $time_used, http_response_code()));
ZLog::Write(LOGLEVEL_DEBUG, "-------- End");
}
}
/**---------------------------------------------------------------------------------------------------------- /**----------------------------------------------------------------------------------------------------------
* private log stuff * private log stuff
*/ */
......
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