Should errors occurred and to be isolated, Rails developer tend to spend hours digest the Rails log files to work out the issues. However this task could become a real nightmare because filtering through megabytes of text to search for specific thing you suspect that go wrong might be very tedious and strenuous. (I know it ’cause I’ve been through cases where log file get up to 60MByes). IMHO, life is too short to be
small  ineffective, so I google-ed around and found this nice piece of gem ‘itslog‘ that could ‘nail the ass’.
itslog is a log formatter designed to aid rails development/debugging. The formatting will prepend all log statements with a colored header and additional information about the statement.
[timestamp] [rails namespace]: [normal log]
Example, default Rails log:
Taxon Load (4.1ms) SELECT "taxons".* FROM "taxons" WHERE "taxons"."parent_id" IS NULL ORDER BY "lft"
19:17:29 active_record: Taxon Load (4.1ms) SELECT "taxons".* FROM "taxons" WHERE "taxons"."parent_id" IS NULL ORDER BY "lft"
The log is now more readable and with the help of ‘cat’ you could extract specific info, for example:
cat log/development.log | grep 'active_record'
Furthermore, you can use ‘tail’ to track specific details from log file:
tail -f log/development.log | grep 'active_record'
Yet even easier, the same author wrote ‘axe‘ which is a wrapper of ‘tail’ to help you generate ‘tail -f’ easily.
$ axe > tail -f log/development.log $ axe active_record > tail -f log/development.log | grep active_record $ axe active_record action_view INSERT > tail -f log/development.log | grep "active_record\|action_view\|INSERT" $ axe -e test > tail -f log/test.log $ axe -e test active_record action_view INSERT > tail -f log/test.log | grep "active_record\|action_view\|INSERT" $ axe -n 50 > tail -n 50 log/development.log $ axe -n 50 INSERT > tail -n 50 log/development.log | grep INSERT
I hope you find ‘itslog’ useful and if you like this post, please subscribe to my blog, I love you 🙂
 <humor>oops, I get mixed up with the protein drink advertising</humor>