This log route tries to solve and add the missing part of the CWebLogRoute.
CWebLogRoute is a great way to get interesting information on the web page but it has it's drawbacks. First of all it display the log every time and it outputs the log on the end of the generated web page and this can make more trouble than good.
The log is placed after the ending html directive, this way it makes non valid HTML markup, and by looking at the web page source you can see the whole long log appended at the end. This troubles me many times while developing. When I want to see the JS code generated by Yii, by going to the end of the file I expect to see the JS code but instead there is the whole log that I need to scroll upward to find the JS code.
Two things I miss most from CWebLogRoute is the possibility to decide when I want to see the log and to see logs from an AJAX call.
That's how the idea of the AWFLogRoute was born.
The main points of this log route is to have valid HTML syntax, clean HTML, show logs only on request and the possibility to show logs for AJAX requests.
When this route is used, the only code added to the web page is a small JS code that generates a button that is used to display the application log. No log data is on the web page, the log is instead saved on a file on the server. In that file there is just the log of the last processed request. If the developer needs to see the application logs for the just executed request, he just needs to click the "Load Application Log" button. At that time an ajax request is executed that gets the logs from the log file and the log is shown on the web page. By clicking "Re-Load Application Log" the log is reloaded with the logs from the last processed request. This can be used after any AJAX request like CGridView pagination, filtering or sorting.
... 'log' => array( 'class' => 'CLogRouter', 'routes' => array( ... array( 'class' => 'application.components.AWFLog.AWFLogRoute', ), ), ), ...
Now it's possible to set the alias for the controller of this extension. This is useful if you place the extension in a folder other than /protected/components/awflog.
For example if you place this extension in the /protected/extension/awflog folder than you can use this settings:
... 'log' => array( 'class' => 'CLogRouter', 'routes' => array( ... array( 'class' => 'ext.AWFLog.AWFLogRoute', 'controllerAlias' => 'ext.AWFLog', ), ), ), ...
The generated buttons and log content can be styled with custom CSS. These are the used IDs
For discussion about this extension follow this forum thread.