Created
January 30, 2018 13:59
-
-
Save askobara/85f6261bdbb2ac392d49125642607df9 to your computer and use it in GitHub Desktop.
Yii2 loggin db profiling
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
'response' => [ | |
'on afterSend' => function ($event) { | |
list($queryCount, $totalExecTime) = Yii::getLogger()->getDbProfiling(); | |
list($mongoQueryCount, $mongoTotalExecutionTime) = mongodb_profiling(); | |
$elapsedTime = Yii::getLogger()->getElapsedTime(); | |
$request = Yii::$app->getRequest(); | |
Yii::info(\yii\helpers\VarDumper::dumpAsString([ | |
'url' => "{$request->getMethod()} {$request->getAbsoluteUrl()}", | |
'body' => $request->getBodyParams(), | |
'db_query_count' => $queryCount, | |
'db_total_execution_time' => $totalExecTime, | |
'mongodb_query_count' => $mongoQueryCount, | |
'mongodb_total_execution_time' => $mongoTotalExecutionTime, | |
'elapsed_time' => $elapsedTime, | |
]), 'perf'); | |
} | |
], |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment