Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
chore(upstream): Adapt change to upstream recommendations
Browse files Browse the repository at this point in the history
Signed-off-by: Francisco Miguel Biete <[email protected]>
<[email protected]>
  • Loading branch information
fmbiete committed Aug 29, 2015
1 parent 8366cc4 commit 9bef557
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
10 changes: 1 addition & 9 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,7 @@
ZPush::GetDeviceManager()->Save();

// end gracefully
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("-------- End - max mem: %s/%s - time: %s - code: %s", memory_get_peak_usage(false), memory_get_peak_usage(true), $time_used, http_response_code()));

ZLog::WriteEnd();

if (defined('LOG_MEMORY_PROFILER') && LOG_MEMORY_PROFILER) {
if (function_exists('memprof_enable')) {
Expand Down
21 changes: 21 additions & 0 deletions lib/core/zlog.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,27 @@ static public function GetLastMessage($loglevel) {
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
*/
Expand Down

0 comments on commit 9bef557

Please sign in to comment.