Sha256: 73dad3f1941a029c9651ef0024bea164602e05d53fbd68af49edefbbea119af1

Contents?: true

Size: 1.68 KB

Versions: 4

Compression:

Stored size: 1.68 KB

Contents

module Raven
  class CLI
    def self.test(dsn = nil, silent = false) # rubocop:disable all
      if silent
        Raven.configuration.logger = ::Logger.new(nil)
      else
        logger = ::Logger.new(STDOUT)
        logger.level = ::Logger::ERROR
        logger.formatter = proc do |_severity, _datetime, _progname, msg|
          "-> #{msg}\n"
        end

        Raven.configuration.logger = logger
      end

      Raven.configuration.timeout = 5
      Raven.configuration.dsn = dsn if dsn

      # wipe out env settings to ensure we send the event
      unless Raven.configuration.capture_allowed?
        env_name = Raven.configuration.environments.pop || 'production'
        Raven.logger.debug "Setting environment to #{env_name}"
        Raven.configuration.current_environment = env_name
      end

      Raven.configuration.verify!

      Raven.logger.debug "Sending a test event:"
      Raven.logger.debug ""

      begin
        1 / 0
      rescue ZeroDivisionError => exception
        evt = Raven.capture_exception(exception)
      end

      if evt && !(evt.is_a? Thread)
        if evt.is_a? Hash
          Raven.logger.debug "-> event ID: #{evt[:event_id]}"
        else
          Raven.logger.debug "-> event ID: #{evt.id}"
        end
      elsif evt # async configuration
        if evt.value.is_a? Hash
          Raven.logger.debug "-> event ID: #{evt.value[:event_id]}"
        else
          Raven.logger.debug "-> event ID: #{evt.value.id}"
        end
      else
        Raven.logger.debug ""
        Raven.logger.debug "An error occurred while attempting to send the event."
        exit 1
      end

      Raven.logger.debug ""
      Raven.logger.debug "Done!"
      true
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sentry-raven-2.1.4 lib/raven/cli.rb
sentry-raven-2.1.3 lib/raven/cli.rb
sentry-raven-2.1.2 lib/raven/cli.rb
sentry-raven-2.1.1 lib/raven/cli.rb