Skip to content

Instantly share code, notes, and snippets.

@fijimunkii
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fijimunkii/9751769 to your computer and use it in GitHub Desktop.
Save fijimunkii/9751769 to your computer and use it in GitHub Desktop.
ruby: error logging
$logfile = File.join(__dir__, '../.log')
$logger = Logger.new($stdout).tap { |log| log.progname = 'MISBEHAVING APP' }
begin
# SSL Stuff
rescue => e
$logger.error e
$logger.error "Check the log file => #{$logfile}"
open($logfile, 'a') do |it|
it << "\n\n#{Time.now}\n"
it << "uncaught #{e} exception while handling connection: #{e.message}\n"
it << "Stack trace: #{e.backtrace.map {|l| " #{l}\n"}.join}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment