Save Db Profiling in db

Hi.

I want to save all queries and their execution time in the db, like in debugger? I’m going to use Logger->getDbProfiling( ).

Maybe there is better way to do it?

So, I added targets into my log config




        'log' => [

            'traceLevel' => YII_DEBUG ? 3 : 0,

            'targets' => [

                [

                    'class' => 'yii\log\DbTarget',

                    'levels' => ['profile'],

                    'logTable' => 'performance_profiling',

                    'categories' => [

                        'yii\db\*',

                    ],

                    'prefix' => function ($message) {

                    $user = Yii::$app->has('user', true) ? Yii::$app->get('user') : null;

                    $userID = $user ? $user->getId(false) : '-';

                    return "[$userID]";

                },

                ],

            ],

        ],




and such tags in the beginning, and at the end of my layout




<?php \Yii::beginProfile('benchmark'); ?>

<?php \Yii::endProfile('benchmark'); ?>



and created table




create table `performance_profiling`

(

   `id`          bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,

   `level`       integer,

   `category`    varchar(255),

   `log_time`    float,

   `prefix`      text,

   `message`     text,

   key `idx_log_level` (`level`),

   key `idx_log_category` (`category`)

) engine InnoDB;



Now I can see all queries made in my site, but I still need to find out how to store execution time. Any ideas?