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

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 )

Facebook photo

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

Connecting to %s