Request log analyzer
One of my discoveries in the last Euruko conference was the project request log analyzer, an improved log analyzer for Rails logs (but also merb and the format you decide). Until now we have used production log analyzer from seattlerb boys, which is still a great tool.
The reason for this change is that request log analyzer let's you define your own parser which was exactly what we needed to parse logs from two of our applications (iwannagothere and partigi.com), because both of them have a mobile version in a different host (the common m.domain host) and we wanted to separate the analysis of these two versions as if they were different applications (they are different, really).
So modify the rails parser was really easy: we only had to change the rails completed line to match the domain of the request:
# Completed in 614ms (View: 120, DB: 31) | 200 OK [http://floorplanner.local/demo]
In this example the domain is floorplanner.local. By default, the regular expression matches the full url: floorplanner.local/demo, but this url is not used in the analysis, so change it didn't supposed a drastic change.
So, we have copied the rails file and modified the rails completed line, with this new regular expression:
RAILS_22_COMPLETED = /Completed in (\d+)ms \((?:View: (\d+), )?DB: (\d+)\) \| (\d\d\d).+\[http:\/\/([^\/]+)\/.+\]/
Now, you have to run request log analyzer indicating the path to your new parser and the parameter --select url m.your_domain. I.e.:
/usr/bin/request-log-analyzer /var/www/partigi/shared/log/production.log --file /tmp/log_partigi --format /var/www/partigi/current/vendor/request-log-analyzer/rails_host.rb --select url m.partigi.com
Easy, isn't it?
