yii\debug\LogTarget::collectSummary PHP Method

collectSummary() protected method

Collects summary data of current request.
protected collectSummary ( ) : array
return array
    protected function collectSummary()
    {
        if (Yii::$app === null) {
            return '';
        }
        $request = Yii::$app->getRequest();
        $response = Yii::$app->getResponse();
        $summary = ['tag' => $this->tag, 'url' => $request->getAbsoluteUrl(), 'ajax' => (int) $request->getIsAjax(), 'method' => $request->getMethod(), 'ip' => $request->getUserIP(), 'time' => time(), 'statusCode' => $response->statusCode, 'sqlCount' => $this->getSqlTotalCount()];
        if (isset($this->module->panels['mail'])) {
            $summary['mailCount'] = count($this->module->panels['mail']->getMessages());
        }
        return $summary;
    }

Usage Example

Example #1
0
 /**
  * @inheritdoc
  */
 protected function collectSummary()
 {
     // get original summary data
     $summary = parent::collectSummary();
     // add in profiling data
     // we do it this way so that the number of files remains
     // consistent between the toolbar and the summary index data
     // this is emulating LogTarget::export()
     foreach ($this->module->panels as $id => $panel) {
         $data = $panel->save();
         if ($id == "profiling") {
             $summary["profilingTime"] = $data["time"];
             $summary["profilingMemory"] = $data["memory"];
             $summary["profilingNumFiles"] = $data["numFiles"];
             break;
         }
     }
     return $summary;
 }