Yii2: Log profiling duration to file

Created on 18 Aug 2015  路  6Comments  路  Source: yiisoft/yii2

Currently the profiling result is not logged to file (or at least I couldn't figure out how to do that). All I get in my logfiles is something like:

2015-08-18 12:07:06 [-][-][-][profile begin][app\export\shop\BaseUpdate::update] Update prices
2015-08-18 12:07:06 [-][-][-][profile end][app\export\shop\BaseUpdate::update] Update prices

So it's missing the actual profiling information about duration.

enhancement

Most helpful comment

@samdark What if use another approach here?

  1. Create separate yii\base\Profiler class with begin() and end() methods (copy beginProfile() and endProfile() from BaseYii).
  2. Make profiler a core component.
  3. Replace BaseYii::beginProfile() contents with Yii::$app->profiler->begin($token, $category), and same with BaseYii::endProfile().

Then everyone will be able to replace profiler with his own implementation. This gives a starting point to solve all "profiler does not work as I need" issues (#8112, #7617, #9458, http://stackoverflow.com/questions/30711195/how-to-profile-a-yii2-based-api/30717856).

All 6 comments

What about imlementing this feature?

Indeed, currently there is no way of profiling database queries and other stuff. There is just no enough information. E. g. for database queries, if we enable profile logging, we can see number of queries and queries itself, but we can't find out how much time it was taken to execute a query.

What prevents #10045 from merging?

@cronfy seems I've somehow missed it. Will review for next release.

@samdark What if use another approach here?

  1. Create separate yii\base\Profiler class with begin() and end() methods (copy beginProfile() and endProfile() from BaseYii).
  2. Make profiler a core component.
  3. Replace BaseYii::beginProfile() contents with Yii::$app->profiler->begin($token, $category), and same with BaseYii::endProfile().

Then everyone will be able to replace profiler with his own implementation. This gives a starting point to solve all "profiler does not work as I need" issues (#8112, #7617, #9458, http://stackoverflow.com/questions/30711195/how-to-profile-a-yii2-based-api/30717856).

@cronfy sounds like a good plan.

Then everyone will be able to replace profiler with his own implementation.

It is already possible to replace standard Logger with your own implementation. What the sense of introduction of another abstraction layer here?

Resolved via #14611

Was this page helpful?
0 / 5 - 0 ratings