Reputation: 128
I have been troubling myself with Yii and currently basically trying to accomplish a chart of data that could be (ajax-)refreshed to different scales (like day, week or month basis). I really would like to use Amcharts-extension, but basically something simpler like EFlot would also do.
Now, to not go to my unique problem, I seem not to be able to generate any kind of error or debug messages from extension (at least from these what I have tried). For example when I try to pass some unknown variable or malformed data to a chart widget, it ends up drawing me a blank sheet with nothing. Nothing here means that the space is reserved but chart is not drawn, no error messages are seen anywhere.
I have the CWebLogRoute
enabled in my main config and it works showing actual Yii errors properly in the page, but for the extensions it does not report anything.
So, what is the proper way to debug extensions in Yii? Is there some generic interface I just have missed or does each extension have their own way to provide error and debug data?
Upvotes: 1
Views: 423
Reputation: 101
If you think the problem is on the server side you can turn on trace logging in your config file (protected/config/main.php by default):
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class' => 'CFileLogRoute',
'levels' => 'error, warning, trace'
),
),
),
and add some Yii::trace() calls to your extensions:
class MyExtension {
public function whatever() {
Yii::trace("Inside MyExtension::whatever()", "MyExtension");
// do some stuff
Yii::trace("Inside MyExtension::whatever(), just did some stuff.", "MyExtension");
}
}
This will insert trace calls into your application.log file (by default this is located in protected/runtime/application.log). They'll look something like this:
2013/02/21 15:35:43 [trace] [MyExtension] Inside MyExtension::whatever()
in /path/to/MyExtension.php (3) 2013/02/21 15:35:43 [trace] [MyExtension] Inside MyExtension::whatever(), just did some stuff in /path/to/MyExtension.php (5)
Put whatever you need into the traces. I'd start with making sure the data you think you're sending from the browser is actually making it to the function to which it's intended to reach in the form in which you expect it. If everything looks normal there then it's time to fire up the web inspector (I prefer Chrome) and watch the Network tab. Take a look at the request to the server and the response delivered. Also check the JS console to be sure nothing's breaking there.
Upvotes: 1