Commit 3d4f2675 authored by Sebastian Kummer's avatar Sebastian Kummer

ZP-945 Print INFO log at end of request incl. all data.

Released under the Affero GNU General Public License (AGPL) version 3.
parent df6fc45e
......@@ -65,10 +65,9 @@ include_once(ZPUSH_CONFIG);
ZLog::Initialize();
ZLog::Write(LOGLEVEL_DEBUG,"-------- Start");
ZLog::Write(LOGLEVEL_INFO,
sprintf("Version='%s' method='%s' from='%s' cmd='%s' getUser='%s' devId='%s' devType='%s'",
@constant('ZPUSH_VERSION'), Request::GetMethod(), Request::GetRemoteAddr(),
Request::GetCommand(), Request::GetGETUser(), Request::GetDeviceID(), Request::GetDeviceType()));
ZLog::Write(LOGLEVEL_DEBUG,
sprintf("cmd='%s' devType='%s' devId='%s' getUser='%s' from='%s' version='%s' method='%s'",
Request::GetCommand(), Request::GetDeviceType(), Request::GetDeviceID(), Request::GetGETUser(), Request::GetRemoteAddr(), @constant('ZPUSH_VERSION'), Request::GetMethod() ));
// Stop here if this is an OPTIONS request
if (Request::IsMethodOPTIONS())
......@@ -230,4 +229,11 @@ include_once(ZPUSH_CONFIG);
ZPush::GetDeviceManager()->Save();
// end gracefully
ZLog::WriteEnd();
ZLog::Write(LOGLEVEL_INFO,
sprintf("cmd='%s' memory='%s/%s' time='%ss' devType='%s' devId='%s' getUser='%s' from='%s' version='%s' method='%s' httpcode='%s'",
Request::GetCommand(), Utils::FormatBytes(memory_get_peak_usage(false)), Utils::FormatBytes(memory_get_peak_usage(true)),
number_format(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 2, ',', '.'),
Request::GetDeviceType(), Request::GetDeviceID(), Request::GetGETUser(), Request::GetRemoteAddr(), @constant('ZPUSH_VERSION'), Request::GetMethod(), http_response_code() ));
ZLog::Write(LOGLEVEL_DEBUG, "-------- End");
......@@ -130,30 +130,6 @@ class ZLog {
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 || (LOGLEVEL_DEBUG <= LOGUSERLEVEL && self::getLogger()->IsAuthUserInSpecialLogUsers())) {
if (version_compare(phpversion(), '5.4.0') < 0) {
$time_used = number_format(time() - $_SERVER["REQUEST_TIME"], 2, ',', '.');
}
else {
$time_used = number_format(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 2, ',', '.');
}
$peakUsage = memory_get_peak_usage(false);
$truePeakUsage = memory_get_peak_usage(true);
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Memory usage information: %s/%s (%s B/%s B) - Execution time: %ss - HTTP responde code: %s",
Utils::FormatBytes($peakUsage), Utils::FormatBytes($truePeakUsage), $peakUsage, $truePeakUsage, $time_used, http_response_code()));
ZLog::Write(LOGLEVEL_DEBUG, "-------- End");
}
}
/**
* Returns the logger object. If no logger has been initialized, FileLog will be initialized and returned.
*
......
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