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.
Config example:
... 'log' => array( 'class' => 'CLogRouter', 'routes' => array( ... array( 'class' => 'application.components.AWFLog.AWFLogRoute', ), ), ), ...
Update v.0.3
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.
Total 4 comments
Thanks Alexey
I updated the extension to incorporate your code, and added more information about the request... now at the top the requested URI is displayed together with the request type (GET,POST,...) and the green word AJAX if the log is for an AJAX request.
mdomba, thank you for this extension!
I use 'enableCsrfValidation'=>true and to make all works properly I added a parameter "data" into ajax request in the AWFLogRoute::init():
As this is just a log route that replaces CWebLogRoute I really don't see the point in uploading screenshots or even a whole demo. If you ever used CWebLogRoute this is the same...
The difference is that you don't see the log on the page until you click on the button "Load Application Log"...
Sounds really nice, could you please attach some screenshots or upload a demo? I dont like downloading+installing just to see how it looks like.
Leave a comment
Please login to leave your comment.