Last active
August 29, 2015 13:57
-
-
Save fijimunkii/9751769 to your computer and use it in GitHub Desktop.
ruby: error logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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