Last Updated: February 25, 2016
·
655
· jedschneider

Rails log mixin

Sometimes when you're running a spec, or in particular a cucumber scenario, its nice to be able to watch the log to see where the error is getting thrown. Sometimes its even nicer to see each step and then the log partial that is associated with processing that step. We can use a little linux trick to help us do that:

$ tail -f logs/test.log &
$ cucumber features/my.feature

We stick the tail process in the background with &

You'll get the rails log mixed into your feature steps as the log gets displayed to standard out. To kill the background process bring the job to the front:

$ fg

And kill with ctl-c as usual. If you have backgrounded several jobs, you can get a list with jobs and kill the process with kill

Thanks for reading!