20.11.2014 Views

O Guia Definitivo do Yii 1.1

O Guia Definitivo do Yii 1.1

O Guia Definitivo do Yii 1.1

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Info: Using skin may degrade the performance because <strong>Yii</strong> needs to look for the skin<br />

file the first time a widget is being created.<br />

Skin is very similar to the global widget customization feature. The main differences are as<br />

follows.<br />

• Skin is more related with the customization of presentational property values;<br />

• A widget can have multiple skins;<br />

• Skin is themeable;<br />

• Using skin is more expensive than using global widget customization.<br />

Registros (Logs)<br />

<strong>Yii</strong> provides a flexible and extensible logging feature. Messages logged can be classified<br />

according to log levels and message categories. Using level and category filters, selected<br />

messages can be further routed to different destinations, such as files, emails, browser<br />

win<strong>do</strong>ws, etc.<br />

Message Logging<br />

Messages can be logged by calling either <strong>Yii</strong>::log or <strong>Yii</strong>::trace. The difference between<br />

these two methods is that the latter logs a message only when the application is in debug<br />

mode.<br />

<strong>Yii</strong>::log($message, $level, $category);<br />

<strong>Yii</strong>::trace($message, $category);<br />

When logging a message, we need to specify its category and level. Category is a string in<br />

the format ofxxx.yyy.zzz which resembles to the path alias. For example, if a message is<br />

logged in CController, we may use the category system.web.CController. Message level<br />

should be one of the following values:<br />

• trace: this is the level used by <strong>Yii</strong>::trace. It is for tracing the execution flow of the<br />

application during development.<br />

• info: this is for logging general information.<br />

• profile: this is for performance profile which is to be described shortly.<br />

• warning: this is for warning messages.<br />

• error: this is for fatal error messages.<br />

Message Routing<br />

Messages logged using <strong>Yii</strong>::log or <strong>Yii</strong>::trace are kept in memory. We usually need to<br />

display them in browser win<strong>do</strong>ws, or save them in some persistent storage such as files,<br />

emails. This is called message routing, i.e., sending messages to different destinations.<br />

In <strong>Yii</strong>, message routing is managed by a CLogRouter application component. It manages a<br />

set of the so-calledlog routes. Each log route represents a single log destination.<br />

Messages sent along a log route can be filtered according to their levels and categories.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!