Skip to content

Instantly share code, notes, and snippets.

@lhz
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save lhz/404da9d10dc93d240805 to your computer and use it in GitHub Desktop.

Select an option

Save lhz/404da9d10dc93d240805 to your computer and use it in GitHub Desktop.
Timestamped rack.errors log
class App < Sinatra::Base
error_log = File.new('log/rack_errors.log', 'a+')
error_log.sync = true
def error_log.puts(*messages)
messages.first.prepend "[#{Time.now.strftime '%F %X.%6N'}] "
super
end
before do
env["rack.errors"] = error_log
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment