module ExceptionNotifier
Public Class Methods
notify_exception(exception, options={})
click to toggle source
# File lib/exception_notification_moderate/exception_notifier.rb, line 8 def notify_exception(exception, options={}) ex_key = exception_key(exception) val = execute_with_rescue_error { redis.get(ex_key) } if val && val.to_i + 60 > Time.now.to_i # Write log and return. ExceptionNotificationModerate.logger.info(exception) return false end execute_with_rescue_error { redis.set(ex_key, Time.now.to_i) } original_notify_exception(exception, options) end
Also aliased as: original_notify_exception
Private Class Methods
exception_key(exception)
click to toggle source
# File lib/exception_notification_moderate/exception_notifier.rb, line 24 def exception_key(exception) "#{exception.to_s}_#{exception.message}" end
execute_with_rescue_error() { || ... }
click to toggle source
# File lib/exception_notification_moderate/exception_notifier.rb, line 28 def execute_with_rescue_error yield rescue Redis::CannotConnectError, SocketError end
redis()
click to toggle source
# File lib/exception_notification_moderate/exception_notifier.rb, line 33 def redis if ExceptionNotificationModerate.redis_host Redis.new(host: ExceptionNotificationModerate.redis_host) elsif ExceptionNotificationModerate.redis_url Redis.new(host: ExceptionNotificationModerate.redis_url) end end