-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
重写yii2-debugger组件,修复yii2-debuuger工具栏显示的时间问题
- Loading branch information
Showing
13 changed files
with
196 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* Author: lf | ||
* Blog: https://blog.feehi.com | ||
* Email: job@feehi.com | ||
* Created at: 2017-12-23 12:40 | ||
*/ | ||
|
||
namespace feehi\debug; | ||
|
||
|
||
use yii; | ||
use yii\helpers\Url; | ||
|
||
class Module extends \yii\debug\Module | ||
{ | ||
public function init() | ||
{ | ||
parent::init(); | ||
$this->setViewPath('@vendor/yiisoft/yii2-debug/views'); | ||
} | ||
|
||
public function setDebugHeaders($event) | ||
{ | ||
if (!$this->checkAccess()) { | ||
return; | ||
} | ||
$url = Url::toRoute(['/' . $this->id . '/default/view', | ||
'tag' => $this->logTarget->tag, | ||
]); | ||
$event->sender->getHeaders() | ||
->set('X-Debug-Tag', $this->logTarget->tag) | ||
->set('X-Debug-Duration', number_format((microtime(true) - yii::$app->getLog()->yiiBeginAt) * 1000 + 1)) | ||
->set('X-Debug-Link', $url); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
/** | ||
* Author: lf | ||
* Blog: https://blog.feehi.com | ||
* Email: job@feehi.com | ||
* Created at: 2017-12-23 12:51 | ||
*/ | ||
namespace feehi\debug\panels; | ||
|
||
use yii; | ||
use yii\log\Logger; | ||
|
||
class ProfilingPanel extends \yii\debug\panels\ProfilingPanel | ||
{ | ||
public function save() | ||
{ | ||
$target = $this->module->logTarget; | ||
$messages = $target->filterMessages($target->messages, Logger::LEVEL_PROFILE); | ||
return [ | ||
'memory' => memory_get_peak_usage(), | ||
'time' => microtime(true) - yii::$app->getLog()->yiiBeginAt, | ||
'messages' => $messages, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* Author: lf | ||
* Blog: https://blog.feehi.com | ||
* Email: job@feehi.com | ||
* Created at: 2017-12-23 12:53 | ||
*/ | ||
|
||
namespace feehi\debug\panels; | ||
|
||
|
||
use yii; | ||
|
||
class TimelinePanel extends \yii\debug\panels\TimelinePanel | ||
{ | ||
public function save() | ||
{ | ||
return [ | ||
'start' => yii::$app->getLog()->yiiBeginAt, | ||
'end' => microtime(true), | ||
'memory' => memory_get_peak_usage(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* Author: lf | ||
* Blog: https://blog.feehi.com | ||
* Email: job@feehi.com | ||
* Created at: 2017-12-23 12:24 | ||
*/ | ||
|
||
namespace feehi\web; | ||
|
||
class Dispatcher extends \yii\log\Dispatcher | ||
{ | ||
public $yiiBeginAt; | ||
|
||
public function getElapsedTime() | ||
{ | ||
return microtime(true) - $this->yiiBeginAt; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
/** | ||
* Author: lf | ||
* Blog: https://blog.feehi.com | ||
* Email: job@feehi.com | ||
* Created at: 2017-12-23 13:48 | ||
*/ | ||
|
||
namespace feehi\web; | ||
|
||
|
||
class Logger extends \yii\log\Logger | ||
{ | ||
public function init() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters