How to add the file name and line number in Rails\' log message? My current format is something like
[INFO : 12-09-27 10:12:30]
I want to chang
Create an initializer logger.rb
in your config/initializers
directory and try putting this
class Logger::SimpleFormatter
def call(severity, time, progname, msg)
"[#{severity} #{time} #{caller(0).first.match(/.*:\d+/)[0]}] #{msg}\n"
end
end
Should work on Ruby 1.9+
In case any one is looking for a similar solution for Rails 4. It would be:
class ActiveSupport::Logger::SimpleFormatter
def call(severity, time, progname, msg)
"[#{severity} #{time} #{caller(0).first.match(/.*:\d+/)[0]}] #{msg}\n"
end
end