Wrong behaviour of Yii:log() method and possible solution

Hi,

I added CLogRoute to log to Firebug console using FirePHP, which is very handy when dealing with Ajax request and JSON responses. It works great, but I found that arrays are logged as "Array" despite FirePHP has very nice feature to display contents of arrays in a very nice way.

I added just one condition (check for array - is_array($msg)) in the YiiBase::log method body to make it work with arrays properly, and would like to share my solution here:


if(!isset(self::$_coreClasses[$className]) && $className!=='YiiBase' [b]&& !is_array($msg)[/b])

{

$msg.="\nin ".$trace['file'].' ('.$trace['line'].')';

if(++$count>=YII_TRACE_LEVEL)

break;

}



I think it’s a good idea to pass $msg parameter to CLogger::log unchanged so any logger could apply own rules on how to display it.

Regards,

Roman