I am now looking for a solution for this for a couple of days now.
Some of my modules are already live, while some modules are still in production. Therefore I would like to be able to enable logging in Webbrowser (CWebLogRoute and CProfileLogRoute) just in a few modules. It would also help, when I could activate logging just for a few users.
As I am asking about logging, I have another question, Is there a better way to see the content of a variable than using print_f and outputting it within the layout. Maybe there is a variable debugger in Yii?!?!
I quickly tested CVarDumper, looks good, but it is not exactly what I was thinking about. The class outputs the variable right where I put it in the source code. I was looking for something like console.log() in javascript or what I just tried Yii::log(), but I can just enter a string here… Is there a better solution?
Surely you can log a variable with Yii::log(). And if you consider file logging, you can define a route that logs your custom category to a different file.
This will work (there may be better choices than print_r)
Yii::log('log a var: '.print_r($_GET,true), 'info', 'mycategory');
Notice: Indirect modification of overloaded element of CMap has no effect in C:\xampp\htdocs\…\components\Controller.php on line 34
Indirect modification of overloaded element of CMap has no effect
I tried to enable like this
//Enable logging only for developers
if(in_array($uid, Yii::app()->params['developers']))
Yii::app()->log->routes['weblogging']->enabled = true;
I don’t get the warning message, which may explain why I didn’t add the usual “untested” disclaimer to my previous post. Obviously what I suggested doesn’t take effect.
Just checked if setting enabled in config will take effect. Seems like it doesn’t. (I based my suggested solution on this.)