A few questions about CGridView

I’m telling you. I don’t know what I did or what I didn’t, but just with default configuration of CLogRouter:


'log'=>array

(

    	'class'=>'CLogRouter',

    	'routes'=>array

    	(

            	array

            	(

                    	'class'=>'CWebLogRoute',

//                                    	'showInFireBug'=>true,

            	),

    	),

),

I see nothing (neither SQL nor hints if there are any except warnings and errors) if there isn’t any error or warning in my application. I’m not quite sure if I also see warnings. Up until now errors was all I saw, if I’m not mistaken. I thought this is normal condition, but today I discovered that I have only class name in CWebLogRoute configuration (i.e. all other options set to default) and according to documentation, I should see something more than just errors.

The only thing I see are AJAX requests logs presented in Firebug, but I see them all the time, no matter if showInFirebug option is set to true or to false. I see nothing else in Firebug and nothing at all on page, if there is no error in my application. To be honest, the only difference between having showInFirebug on or off I noticed is that, if there is error, exception is displayed in either console or page. In any situation or combination of loggin configuration I have never seen even a piece of SQL, neither in page nor in Firebug.

I’ve enabled ‘enableParamLogging’=>true, following your advice, but currently it does not change anything here, as right now I don’t see any SQL, neither with nor without parameters binding.

I would be glad, if I would see any SQL from my application, cause currently I can’t - don’t know why?

Strange… Do you have the "application log" under your view like in the picture?

No, I don’t! :[ I only have those nice, pink exception fields in case of error.

I’ll take a look later this day (at home) to test logging on freshly generated Yii application, to see if there isn’t error somewhere in my code (probably is). But this seems to be strange, as I have pure, defaulted configuration of logging component.

seems you don’t have it enabled at all… check that your ‘log’ is inside the ‘conponents’

Can I have logging component not enabled and be able to see exceptions (errors) as either addition to webpage or notice in Firebug console? :]

But, as I wrote above, I’ll double check it from home and post here, if I find something.

All right, sorry for the expression, but now I have no bloody idea, what is going on? :confused:

Once again, for clearing things out. Here is my complete log component configuration:


'log'=>array

(

    	'class'=>'CLogRouter',

    	'routes'=>array

    	(

            	array

            	(

                    	'class'=>'CFileLogRoute',

                    	'levels'=>'error, warning',

            	),				

            	array

            	(

                    	'class'=>'CWebLogRoute',

            	),

    	),

),

This one was copied from a new, freshly generated application. Works there (I see trace level logs) does not work in my main project (where I see only error logs)! :expressionless:

Though my configuration of main project didn’t differ from the one above, I copied log part from fresh app to current project to make sure. No difference - trace logging works in a new application and doesn’t work in main project. To be even more sure I copied back this part of code from main project to fresh application, to assure myself that NetBeans or Windows does not adds some invisible chars, that could change something (idiotic assumption, but I wanted to check every possibility). No effect. Seems that the very same piece of code works in one application and doesn’t work in another.

Do you have any idea, what else I could check to get know, why I see only errors in one project and full logging in another one?

Just to be sure…

at the beginning of the configuration do you have


'preload' => array('log'),

and is the ‘log’ components inside the ‘components’ array?

config\main.php




return array(

   ...

   'preload'=>array('log'),

   ...

   'components'=>array(

   ...

   'log'=>array(...),

   ...

   )

   ...

)



I have ‘preload’ => array(‘log’) at beginning of configuration array and I have ‘log’ component declaration inside the ‘components’ array.

The only difference is that my configuration file is protected/configuration/base.php, but I don’t think that this could cause any problems, since there is a correct path given in index.php and since application is working without problem (except not displaying trace messages) therefore has access to configuration file.

Even more, I copied whole configuration array from freshly generated application (where web-tracing were enabled and of course - working), overwrote with it my project’s configuration and only changed lines that are required to run application (i.e. removed name, modified errorAction, added defaultController and my own config component, essential in running application). Even then I saw no trace messages or SQL, only error reports. I’m beginning to think that problem lies somewhere outside configuration file but have no idea, what and where can be wrong?

It would be much easier to detect source of this problem, if I would not see any log. But situation, where I see errors, not seeing trace messages is very strange to me.

Perhaps you’ll need to add this to your start script




// specify how many levels of call stack should be shown in each log message

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);



/Tommy

Thanks! For the first moment I thought that you found solution for my problem, as I was commenting-out these lines in some of my projects. I was even ready to take well deserved label of being uber-moron for not finding so obvious solution. But then a cruel reality come as I notice that in this particular project (and in another one, build on the first one) I have this lines not commented out, i.e. in both cases these constants are declared in bootstrap file.

Conclusion for this moment is, that whatever causes now two of my applications to display only error messages and not traces logs or SQLs, is neither located in configuration not in bootstrap file. Must be somewhere in the code, but I’m running out of ideas where and what can be causing such strange behaviour?

BTW: Can anyone give me any idea, how can I generate a warning-level message in my application? So I can test if I see only errors or do I see also warnings and trace level messages and SQLs are the only one I don’t see? Cause up until now I was only able to generate error-level problem in both of my apps that refuses to display traces and SQLs.

According to the API reference you can specify level as parameter 2 to the Yii::log() method.

/Tommy

Thanks again, Tommy! And sorry for not finding it myself in the documentation…

This is one of these few situations, when I cite myself! :]

Not necessary! I believe I well deserved for moron label! :]

It turned out that following Qiang’s artice on using shortcut functions to reduce typing, I mistakenly moved require_once($yii); above definition of debug constants. Where proper part of the definitive guide says enough clearly: To run in debug mode, define this constant as true before including the yii.php file.

Problem solved. I’m moron. End of topic. Thank you! :]

Don’t be too harsh on yourself…

It’s a good thing you found the mistake… so you are not a lost case :)

And at least we now have all this documented for others that could make similar mistake :blink:

Going back to roots, i.e. to main topic…

This discussion continues in this topic, where Tommy explained that, we can see SQLs executed by AJAX calls, if we turn on file logging (CFileLogRoute) and look into protected/runtime/application.log file.

Hello,

don’t know if your problem searching for empty values is already solved.

However, I had a similar issue and figured out this.

  1. In the _search.php template, display user instructions to enter ‘EMPTY’ in order to search for empty values.

  2. Model / Function search()




if(isset($this->fieldToSearch) and $this->fieldToSearch=='EMPTY')

	$criteria->addCondition("t.fieldToSearch=''");

else

	$criteria->compare('fieldToSearch',$this->fieldToSearch,true);



Hope this helps.

Regards,

Joachim

Thanks, Joachim!

Seems to be a very good, yet simple, idea on theoretical ground. I’ll keep it in mind for my future projects.

The project I’ve been working on, when asking these question is already finished and I’m quite not on it, so I can’t check if this would be an option, what you propose.

But thanks again, even so,

Trejder