Beautiful way to log IP.

Hello every1. I’m kinda new ti this framework, but i find it very nice and easy to learn=).

So here’s my question: I whana log IP in my exceptions and errors like i log username and id with CLogFilter.

I’ve only found 2 ways to do it:

[list=1]

[*]Place some code for it in CLogFilter.format

[*]extend CLogFilter to do so.

[/list]

I would be glad if any1 point me better solution.

Extend CLogFilter and rewrite the function you need.

You can place your class in compoment and include in main config:


'log'=>array(

			'class'=>'CLogRouter',

			'routes'=>array(

				array(

					'class'=>'MyLogFilter', // the class you extended

					'levels'=>'error, warning',

				),

			),

		),

I meant, is there some buildin functionality that i can use.

Looking at the documentation there is no configuration for this detail, but the method format is protected, that means that is meant to be overridden.

Extending framework object is normal routine when you have to do some task that is not implemented, don’t think that is not stylish!

Yii makes me lazy - it does almost everything itself =))) So i thought that i’ll just say some magic words and it’ll do what i want =)

Well, you have just to say some magic word in a class file…

I think that you can do with less than 15 lines of code.

15 lines in extension file =)