Yii Framework Forum: 如何在框架代码中打Log - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

如何在框架代码中打Log Rate Topic: -----

#1 User is offline   gallen83 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 08-February 13

Posted 08 February 2013 - 01:07 AM

我刚刚接触Yii,为了测试翻译的用法,写了如下语句:echo Yii::t('post','1#one book|n>1#many books',array(2)); 并且在messages加入了zh_cn文件夹,在文件夹中加了post.php,内容如下:
return array(
'one book' => '一本书',
'many books' => '许多本书'
);
但是发现,程序运行时,并没有正确的翻译成中文。
所以我想跟踪Yii::t这个函数看看如何实现的, 在yiilite.php里面的public static function t($category,$message,$params=array(),$source=null,$language=null)函数里面写了Yii::log('source:'.$source);。 但是在log中没有看到这个记录,请大家帮忙,我如何能在framework中打印出log,这样在我学习和跟踪代码的时候都能有帮助。谢谢
0

#2 User is offline   gallen83 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 08-February 13

Posted 08 February 2013 - 01:20 AM

View Postgallen83, on 08 February 2013 - 01:07 AM, said:

我刚刚接触Yii,为了测试翻译的用法,写了如下语句:echo Yii::t('post','1#one book|n>1#many books',array(2)); 并且在messages加入了zh_cn文件夹,在文件夹中加了post.php,内容如下:
return array(
'one book' => '一本书',
'many books' => '许多本书'
);
但是发现,程序运行时,并没有正确的翻译成中文。
所以我想跟踪Yii::t这个函数看看如何实现的, 在yiilite.php里面的public static function t($category,$message,$params=array(),$source=null,$language=null)函数里面写了Yii::log('source:'.$source);。 但是在log中没有看到这个记录,请大家帮忙,我如何能在framework中打印出log,这样在我学习和跟踪代码的时候都能有帮助。谢谢

我发现在YiiBase中可以打印log
0

#3 User is offline   hehbhehb 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 24-February 12

Posted 08 February 2013 - 07:59 AM

index.php中默认是执行yii.php,而不是yiilite.php的. 你在yiilite.php中写的log当然不会被执行.
http://www.yiiframew...ics.performance
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users