Permalink
Browse files

Fixes #179: Increased request time logging accuracy and precision

  • Loading branch information...
1 parent 7b0e057 commit 454d89c28ded42003602eeb7d01dc1614871d832 @samdark samdark committed Dec 14, 2016
Showing with 17 additions and 2 deletions.
  1. +1 −1 CHANGELOG.md
  2. +16 −1 LogTarget.php
View
@@ -4,7 +4,7 @@ Yii Framework 2 debug extension Change Log
2.0.8 under development
-----------------------
-- no changes in this release.
+- Enh #179: Increased request time logging accuracy and precision (samdark)
2.0.7 under development
View
@@ -152,7 +152,7 @@ protected function collectSummary()
'ajax' => (int) $request->getIsAjax(),
'method' => $request->getMethod(),
'ip' => $request->getUserIP(),
- 'time' => time(),
+ 'time' => $this->getRequestTime(),
'statusCode' => $response->statusCode,
'sqlCount' => $this->getSqlTotalCount(),
];
@@ -165,6 +165,21 @@ protected function collectSummary()
}
/**
+ * Returns request time in seconds
+ *
+ * @return float request time in seconds
+ * @since 2.0.8
+ */
+ protected function getRequestTime()
+ {
+ if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
+ return $_SERVER['REQUEST_TIME_FLOAT'];
+ }
+
+ return microtime(true);
+ }
+
+ /**
* Returns total sql count executed in current request. If database panel is not configured
* returns 0.
* @return int

0 comments on commit 454d89c

Please sign in to comment.