Simple error logging for Sinatra

Writes to console and outputs to log…

error_logger = Logger.new('log/errors.log')
error do
  e = request.env['sinatra.error']
  info = "Application error\n#{e}\n#{e.backtrace.join("\n")}"

  error_logger.info info
  Kernel.puts info

  'Application error'
end
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s