Sha256: 14c7bdae97db44874c82ca3a9b97c70f87e25f9fe0fef0752c002a5df74b1c58

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

require 'raven'

module Raven
  class CLI
    def self.test(dsn=nil)
      require 'logger'

      logger = ::Logger.new(STDOUT)
      logger.level = ::Logger::ERROR
      logger.formatter = proc do |severity, datetime, progname, msg|
        "-> #{msg}\n"
      end

      Raven.configuration.logger = logger

      if dsn then
        Raven.configuration.dsn = dsn
      end

      # wipe out env settings to ensure we send the event
      if !Raven.configuration.send_in_current_environment? then
        env_name = Raven.coniguration.environments[0]
        puts "Setting environment to #{env_name}"
        Raven.configuration.current_environment = env_name
      end

      if !Raven.configuration.server then
        puts "Your client is not configured!"
        exit 1
      end

      puts "Client configuration:"
      ['server', 'project_id', 'public_key', 'secret_key'].each do |key|
        if !Raven.configuration[key] then
          puts "Missing configuration for #{key}"
          exit 1
        end
        puts "-> #{key}: #{Raven.configuration[key]}"
      end
      puts ""

      puts "Sending a test event:"

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

      if evt then
        puts "-> event ID: #{evt.id}"
      else
        puts ""
        puts "An error occurred while attempting to send the event."
        exit 1
      end

      puts ""
      puts "Done!"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sentry-raven-0.4.8 lib/raven/cli.rb
sentry-raven-0.4.7 lib/raven/cli.rb