I have a ruby console application. When I check it in irb on my dev machine, it logs ok. But when I run it in VM ruby logger loses formatting, i.e. it logs only message, without date and severity. Now this is solved by setting formatting with Logger.formatter = proc { |severity, datetime, progname, msg| ...}. But I'm curious as to why that could happen? I googled and found rather old info that this could happen in Rails application. Is this a known issue? It took me some time to debug this.
Are you requireing different gems in the different environments, or could it be IRB itself that sets the log format? What happens if you add require 'irb' to your application, does that also change the formatting?
The formatting is stored in a global variable, any gem can override it. I've been bitten by a similar issue when I required a gem that in turn required ActiveRecord, which set the log format.
It just shows how bad it is to use global variables for configuration, something that is way too common in Ruby gems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With