Tuesday, August 13, 2013

Adding Process ID and timestamps to the Rails Logger

For the last few days, I've been trying to debug a race condition between several Delayed::Job workers.  After looking at log files for many hours, it became very frustrating to not know which one of my 3 workers was writing which statement.  I finally found this post which almost did what I wanted.

To add process ids and timestamps to your Rails logs, you can add this as a Rails initializer (config/initializers/log_formatting.rb for instance) and restart your application / workers:

Wednesday, May 8, 2013

How to write a simple Rails gem

Today, I wrote my first Ruby on Rails gem.  It was a very simple refactoring of our code that I undertook when I needed to add the same functionality to a new model and I decided to do it as a gem instead of keeping it within our project.  I wanted to see how it worked and this is what I ended up with.  You can follow the Rails Guide, but it didn't cover everything I wanted to do.