Skip to content

Instantly share code, notes, and snippets.

@longlostnick
Created May 12, 2017 21:23
Show Gist options
  • Save longlostnick/91b19ac9ed0e4c47e80dec40d2d7d35d to your computer and use it in GitHub Desktop.
Save longlostnick/91b19ac9ed0e4c47e80dec40d2d7d35d to your computer and use it in GitHub Desktop.
Ruby logger helper method for friendly logging of exceptions with stack trace.
class Logger
def exception(e, level=:error)
self.send level, "#{e.inspect} #{e.message}"
self.send level, " #{e.backtrace.first(25).join("\n ")}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment