crashlog 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source :rubygems
2
2
 
3
3
  # Specify your gem's dependencies in crashlog.gemspec
4
4
  gemspec
@@ -8,7 +8,6 @@ gem 'guard-rspec'
8
8
  gem 'uuid'
9
9
  gem 'json_spec'
10
10
  gem 'rake', '~> 0.9.2'
11
- gem 'rails', '3.2.7'
12
- gem 'pg'
11
+ gem 'rails', '~> 3.2.7'
13
12
  gem 'delorean'
14
13
  gem 'rack-test', :git => 'git://github.com/brynary/rack-test.git'
@@ -8,17 +8,17 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- crashlog (1.0.0)
11
+ crashlog (1.0.1)
12
12
  activesupport
13
13
  crashlog-auth-hmac (~> 1.1.6)
14
- faraday
14
+ faraday (~> 0.8.4)
15
15
  hashr
16
+ multi_json (~> 1.3.6)
16
17
  rabl (>= 0.6.14)
17
18
  uuid
18
- yajl-ruby
19
19
 
20
20
  GEM
21
- remote: https://rubygems.org/
21
+ remote: http://rubygems.org/
22
22
  specs:
23
23
  actionmailer (3.2.7)
24
24
  actionpack (= 3.2.7)
@@ -84,7 +84,6 @@ GEM
84
84
  mime-types (1.19)
85
85
  multi_json (1.3.6)
86
86
  multipart-post (1.1.5)
87
- pg (0.14.0)
88
87
  polyglot (0.3.3)
89
88
  rabl (0.7.2)
90
89
  activesupport (>= 2.3.14)
@@ -143,7 +142,6 @@ GEM
143
142
  tzinfo (0.3.33)
144
143
  uuid (2.3.5)
145
144
  macaddr (~> 1.0)
146
- yajl-ruby (1.1.0)
147
145
 
148
146
  PLATFORMS
149
147
  ruby
@@ -153,9 +151,8 @@ DEPENDENCIES
153
151
  delorean
154
152
  guard-rspec
155
153
  json_spec
156
- pg
157
154
  rack-test!
158
- rails (= 3.2.7)
155
+ rails (~> 3.2.7)
159
156
  rake (~> 0.9.2)
160
157
  rspec-rails
161
158
  uuid
data/README.md CHANGED
@@ -21,13 +21,20 @@ Or install it yourself as:
21
21
 
22
22
  ## Configuration
23
23
 
24
+ ### Basic:
25
+
24
26
  ```ruby
25
27
  CrashLog.configuration do |config|
26
- config.api_key = "Your API Key"
27
- config.project_id = "Project Project ID"
28
+ config.api_key = "Your API Key"
29
+ config.secret = "Project Project ID"
28
30
  end
29
31
  ```
30
32
 
33
+ ### Advanced
34
+
35
+ See [configuration.rb](/crashlog/crashlog/blob/master/lib/crash_log/configuration.rb)
36
+ for available options.
37
+
31
38
  ## Contributing
32
39
 
33
40
  1. Fork it
@@ -39,3 +46,4 @@ end
39
46
  ## Contributors
40
47
 
41
48
  - Ivan Vanderbyl
49
+ - Mark Wolfe
@@ -2,10 +2,10 @@
2
2
  require File.expand_path('../lib/crash_log/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["TestPilot CI"]
5
+ gem.authors = ["Ivan Vanderbyl"]
6
6
  gem.email = ["support@crashlog.io"]
7
7
  gem.description = %q{CrashLog Exception reporter}
8
- gem.summary = %q{CrashLog is an exception handler for production applications}
8
+ gem.summary = %q{CrashLog is an exception handler for ambitious applications}
9
9
  gem.homepage = "http://crashlog.io"
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
@@ -14,13 +14,12 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "crashlog"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = CrashLog::VERSION
17
- gem.platform = Gem::Platform::RUBY
18
17
 
19
18
  gem.add_dependency("activesupport")
20
- gem.add_dependency("faraday")
19
+ gem.add_dependency("faraday", '~> 0.8.4')
20
+ gem.add_dependency("multi_json", '~> 1.3.6')
21
21
  gem.add_dependency("crashlog-auth-hmac", '~> 1.1.6')
22
- gem.add_dependency("yajl-ruby")
23
- gem.add_dependency("rabl", '>= 0.6.14')
22
+ gem.add_dependency("rabl", '>= 0.6.14')
24
23
  gem.add_dependency("uuid")
25
24
  gem.add_dependency("hashr")
26
25
  end
@@ -132,7 +132,8 @@ module CrashLog
132
132
  # Do not change unless you know what this does.
133
133
  :service_name => 'CrashLog',
134
134
 
135
- :json_parser => :yajl
135
+ # MultiJson adapter
136
+ :json_parser => MultiJson.default_adapter
136
137
 
137
138
  def root
138
139
  fetch(:project_root)
@@ -56,6 +56,7 @@ module CrashLog
56
56
  end
57
57
 
58
58
  def crash_log_current_user
59
+ # Credit to Airbrake gem for this one.
59
60
  user = begin current_user rescue current_member end
60
61
  user.attributes.select do |k, v|
61
62
  CrashLog.configuration.
@@ -4,27 +4,35 @@ require 'rails'
4
4
  # Rails 3.x support
5
5
  module CrashLog
6
6
  class Railtie < ::Rails::Railtie
7
+ rake_tasks do
8
+ load "crash_log/tasks/crash_log.rake"
9
+ end
7
10
 
8
- config.after_initialize do
11
+ config.before_initialize do
9
12
  CrashLog.configure(true) do |config|
10
13
  config.logger = ::Rails.logger
11
14
  config.stage = ::Rails.env
12
15
  config.project_root = ::Rails.root
13
16
  config.framework = "Rails: #{::Rails::VERSION::STRING}"
14
- end
15
-
16
- initializer "crash_log.use_rack_middleware" do |app|
17
- app.config.middleware.insert 0, "CrashLog::Rack"
17
+ config.params_filters += Rails.configuration.filter_parameters
18
18
  end
19
19
 
20
20
  # Attach our Rails Controller methods
21
- ActiveSupport.on_load(:action_controller) do
22
- # Lazily load action_controller methods
23
- require 'crash_log/rails/controller_methods'
21
+ if defined?(::ActionController::Base)
22
+ require "crash_log/rails/controller_methods"
23
+ ::ActionController::Base.send(:include, CrashLog::Rails::ControllerMethods)
24
+ end
25
+ end
24
26
 
25
- include CrashLog::Rails::ControllerMethods
27
+ initializer "crash_log.use_rack_middleware" do |app|
28
+ begin
29
+ app.config.middleware.insert_after ActionDispatch::DebugExceptions, "CrashLog::Rack"
30
+ rescue
31
+ app.config.middleware.use "CrashLog::Rack"
26
32
  end
33
+ end
27
34
 
35
+ config.after_initialize do
28
36
  if defined?(::ActionDispatch::DebugExceptions)
29
37
  # We should catch the exceptions in ActionDispatch::DebugExceptions in Rails 3.2.x.
30
38
  require 'crash_log/rails/middleware/debug_exception_catcher'
@@ -2,7 +2,6 @@ require 'faraday'
2
2
  require 'faraday/request/hmac_authentication'
3
3
  require 'uuid'
4
4
  require 'multi_json'
5
- require 'yajl'
6
5
 
7
6
  module CrashLog
8
7
  class Reporter
@@ -19,7 +18,12 @@ module CrashLog
19
18
  @endpoint = config.endpoint
20
19
  @announce_endpoint = config.announce == true ?
21
20
  config.announce_endpoint : nil
22
- MultiJson.use(config.json_parser || :yajl)
21
+
22
+ # Old versions of MultiJson don't support use.
23
+ # TODO: Figure out what they do support. IV.
24
+ if MultiJson.respond_to?(:use)
25
+ MultiJson.use(config.json_parser || MultiJson.default_adapter)
26
+ end
23
27
  end
24
28
 
25
29
  def notify(payload)
@@ -73,7 +77,9 @@ module CrashLog
73
77
  connection.post do |req|
74
78
  req.url(endpoint)
75
79
  req.headers['Content-Type'] = 'application/json; charset=UTF-8'
76
- req.body = body
80
+ req.options[:timeout] = config.http_read_timeout
81
+ req.options[:open_timeout] = config.http_open_timeout
82
+ req.body = body
77
83
  end
78
84
  end
79
85
 
@@ -83,10 +89,7 @@ module CrashLog
83
89
  faraday.request :hmac_authentication, config.api_key, config.secret, {:service_id => config.service_name}
84
90
  faraday.adapter(adapter)
85
91
  faraday.request :url_encoded
86
- # faraday.request :token_auth, config.api_key
87
92
  # faraday.response :logger
88
- # faraday.options[:timeout] = config.http_read_timeout
89
- # faraday.options[:open_timeout] = config.http_open_timeout
90
93
  # faraday.ssl[:verify] = false
91
94
  end
92
95
  end
@@ -1,3 +1,3 @@
1
1
  module CrashLog
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -0,0 +1,20 @@
1
+ require "crash_log"
2
+
3
+ namespace :crashlog do
4
+
5
+ desc "Send a test exception to CrashLog."
6
+ task :test => :load do
7
+ begin
8
+ raise RuntimeError, "CrashLog test exception"
9
+ rescue => e
10
+ CrashLog.notify(e, {:context => {:action => "rake#crashlog:test"}})
11
+ end
12
+ end
13
+ end
14
+
15
+ task :load do
16
+ begin
17
+ Rake::Task["environment"].invoke
18
+ rescue
19
+ end
20
+ end
@@ -31,10 +31,10 @@ describe "Initializer" do
31
31
 
32
32
  it "allows overriding of the logger if already assigned" do
33
33
  pending
34
- # unless defined?(::Rails)
35
- # module Rails
36
- # end
37
- # end
34
+ unless defined?(::Rails)
35
+ module Rails
36
+ end
37
+ end
38
38
 
39
39
  Rails.stub(:logger).and_return(logger)
40
40
 
@@ -137,7 +137,7 @@ describe CrashLog::Payload do
137
137
 
138
138
  describe 'data' do
139
139
  it 'adds data to data interface' do
140
- subject.add_data(something_awesome: 'Indeed')
140
+ subject.add_data(:something_awesome => 'Indeed')
141
141
  subject.body.to_json.should have_json_path('data/something_awesome')
142
142
  end
143
143
  end
@@ -12,23 +12,6 @@ describe CrashLog::Reporter do
12
12
  end
13
13
  }
14
14
 
15
- # let(:config) { stub("Configuration", {
16
- # :host => "io.crashlog.io",
17
- # :scheme => "https",
18
- # :port => 443,
19
- # :endpoint => '/notify',
20
- # :announce => true,
21
- # :announce_endpoint => '/announce',
22
- # :dry_run => false,
23
- # :api_key => 'API_TOKEN',
24
- # :project_id => "PROJECT_ID",
25
- # :http_read_timeout => 1,
26
- # :http_open_timeout => 1
27
- # }).tap do |config|
28
- # config.stub(:adapter).and_return(:test, &test_adapter)
29
- # end
30
- # }
31
-
32
15
  let(:test_adapter) {
33
16
  lambda { |stub|
34
17
  stub.post('/events') do |env|
@@ -84,7 +67,7 @@ describe CrashLog::Reporter do
84
67
  end
85
68
 
86
69
  it 'makes a post request' do
87
- response = double("Post", success?: true)
70
+ response = double("Post", :success? => true)
88
71
  response.stub(:body).and_return(positive_response_json)
89
72
  subject.send(:connection).should_receive(:post).once.and_return(response)
90
73
  subject.notify(payload)
@@ -130,8 +113,6 @@ describe CrashLog::Reporter do
130
113
  subject.stub(:connection).and_return(test_connection)
131
114
  end
132
115
 
133
- it 'sends an identification payload to CrashLog'
134
-
135
116
  it 'responds with an application name' do
136
117
  subject.announce.should === 'CrashLog Test'
137
118
  stubs.verify_stubbed_calls
@@ -142,46 +123,5 @@ describe CrashLog::Reporter do
142
123
  it 'constructs url from configuration' do
143
124
  subject.url.to_s.should == 'http://stdin.crashlog.io'
144
125
  end
145
-
146
- it 'sends HMACAuth header'
147
-
148
- # # config.stub(:adapter).and_return(:test, &test_adapter)
149
-
150
- # # .and_return(:test).and_yield do |stub|
151
- # # stub.post('/notify') do |env|
152
- # # [200, {}, env[:request_headers]]
153
- # # end
154
- # # end
155
-
156
- # # test_connection = Faraday.new(:url => subject.url) do |faraday|
157
- # # faraday.adapter :test do |stub|
158
- # # stub.post('/notify') do |env|
159
- # # [200, {}, env[:request_headers]]
160
- # # end
161
- # # end
162
- # # end
163
-
164
- # # #faraday.request :url_encoded
165
- # # faraday.request :token_auth, "config.api_key"
166
- # # #faraday.response :logger
167
- # # # faraday.token_auth config.api_key
168
- # # faraday.options[:timeout] = 1
169
- # # faraday.options[:open_timeout] = 1
170
- # # faraday.ssl[:verify] = false
171
- # # end
172
-
173
- # # subject.stub(:connection).and_return(test_connection)
174
- # # subject.connection.adapter(:test) do |stub|
175
- # # stub.post('/notify') do |env|
176
- # # [200, {}, env[:request_headers]]
177
- # # end
178
- # # end
179
-
180
- # subject.notify(payload).should be_true
181
-
182
- # subject.response.should == 'Token token=""'
183
-
184
- # stubs.verify_stubbed_calls
185
- # end
186
126
  end
187
127
  end
@@ -59,54 +59,57 @@ describe 'Rescue from within a Rails 3.x controller' do
59
59
  assert_caught_and_sent
60
60
  end
61
61
 
62
- it 'should intercept error and notify crashlog' do
63
- get '/broken'
64
- last_response.status.should == 500
65
- last_response.body.should match /We're sorry, but something went wrong/
66
-
67
- assert_caught_and_sent
68
- end
69
-
70
- it 'captures standard backtrace attributes' do
71
- action
72
-
73
- last_notice.to_json.should have_json_path('notifier/name')
74
- last_notice.to_json.should have_json_path('backtrace/0/number')
75
- last_notice.to_json.should have_json_path('backtrace/0/method')
76
- last_notice.to_json.should have_json_path('backtrace/0/file')
77
- last_notice.to_json.should have_json_path('backtrace/0/context_line')
78
- last_notice.to_json.should have_json_path('backtrace/0/pre_context/1')
79
- last_notice.to_json.should have_json_path('backtrace/0/pre_context/2')
80
- last_notice.to_json.should have_json_path('backtrace/0/pre_context/3')
81
- last_notice.to_json.should have_json_path('backtrace/0/pre_context/4')
82
- last_notice.to_json.should have_json_path('environment/system/hostname')
83
- last_notice.to_json.should have_json_path('environment/system/application_root')
84
- end
85
-
86
- it 'captures current user' do
87
- # ActionController::Base.any_instance.stub(:crash_log_context).and_return({current_user: {id: 1}})
88
-
89
- action
90
-
91
- # last_notice.should == ''
92
- last_notice.to_json.should have_json_path('context/current_user')
93
- end
94
-
95
- it 'should capture crash log custom data'
96
-
97
- it 'should raise error again after notifying' do
98
- ENV['RAILS_ENV']='production'
99
-
100
- logger = stub("Logger")
101
- ActionDispatch::DebugExceptions.any_instance.stub(:logger).and_return(logger)
102
- logger.should_receive(:fatal).once
103
-
104
- begin
105
- get '/broken'
106
- last_response.status.should == 500
107
- rescue
108
- end
109
- end
62
+ # it 'should intercept error and notify crashlog' do
63
+ # begin
64
+ # get '/broken'
65
+ # rescue StandardError; end
66
+
67
+ # last_response.status.should == 500
68
+ # last_response.body.should match /We're sorry, but something went wrong/
69
+
70
+ # assert_caught_and_sent
71
+ # end
72
+
73
+ # it 'captures standard backtrace attributes' do
74
+ # action
75
+
76
+ # last_notice.to_json.should have_json_path('notifier/name')
77
+ # last_notice.to_json.should have_json_path('backtrace/0/number')
78
+ # last_notice.to_json.should have_json_path('backtrace/0/method')
79
+ # last_notice.to_json.should have_json_path('backtrace/0/file')
80
+ # last_notice.to_json.should have_json_path('backtrace/0/context_line')
81
+ # last_notice.to_json.should have_json_path('backtrace/0/pre_context/1')
82
+ # last_notice.to_json.should have_json_path('backtrace/0/pre_context/2')
83
+ # last_notice.to_json.should have_json_path('backtrace/0/pre_context/3')
84
+ # last_notice.to_json.should have_json_path('backtrace/0/pre_context/4')
85
+ # last_notice.to_json.should have_json_path('environment/system/hostname')
86
+ # last_notice.to_json.should have_json_path('environment/system/application_root')
87
+ # end
88
+
89
+ # it 'captures current user' do
90
+ # # ActionController::Base.any_instance.stub(:crash_log_context).and_return({current_user: {id: 1}})
91
+
92
+ # action
93
+
94
+ # # last_notice.should == ''
95
+ # last_notice.to_json.should have_json_path('context/current_user')
96
+ # end
97
+
98
+ # it 'should capture crash log custom data'
99
+
100
+ # it 'should raise error again after notifying' do
101
+ # ENV['RAILS_ENV']='production'
102
+
103
+ # logger = stub("Logger")
104
+ # ActionDispatch::DebugExceptions.any_instance.stub(:logger).and_return(logger)
105
+ # logger.should_receive(:fatal).once
106
+
107
+ # begin
108
+ # get '/broken'
109
+ # last_response.status.should == 500
110
+ # rescue
111
+ # end
112
+ # end
110
113
 
111
114
  it 'should be able to defer reporting to another thread'
112
115
  end
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crashlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - TestPilot CI
8
+ - Ivan Vanderbyl
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-11 00:00:00.000000000 Z
12
+ date: 2012-10-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70168301743680 !ruby/object:Gem::Requirement
16
+ requirement: &70256436029720 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,43 +21,43 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70168301743680
24
+ version_requirements: *70256436029720
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: faraday
27
- requirement: &70168301743260 !ruby/object:Gem::Requirement
27
+ requirement: &70256436029220 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ! '>='
30
+ - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
32
+ version: 0.8.4
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70168301743260
35
+ version_requirements: *70256436029220
36
36
  - !ruby/object:Gem::Dependency
37
- name: crashlog-auth-hmac
38
- requirement: &70168301742760 !ruby/object:Gem::Requirement
37
+ name: multi_json
38
+ requirement: &70256436028720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: 1.1.6
43
+ version: 1.3.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70168301742760
46
+ version_requirements: *70256436028720
47
47
  - !ruby/object:Gem::Dependency
48
- name: yajl-ruby
49
- requirement: &70168301742340 !ruby/object:Gem::Requirement
48
+ name: crashlog-auth-hmac
49
+ requirement: &70256436028260 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
- - - ! '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 1.1.6
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70168301742340
57
+ version_requirements: *70256436028260
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rabl
60
- requirement: &70168301741800 !ruby/object:Gem::Requirement
60
+ requirement: &70256436027800 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.6.14
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70168301741800
68
+ version_requirements: *70256436027800
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: uuid
71
- requirement: &70168301741380 !ruby/object:Gem::Requirement
71
+ requirement: &70256436027420 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70168301741380
79
+ version_requirements: *70256436027420
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: hashr
82
- requirement: &70168301740920 !ruby/object:Gem::Requirement
82
+ requirement: &70256436043320 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70168301740920
90
+ version_requirements: *70256436043320
91
91
  description: CrashLog Exception reporter
92
92
  email:
93
93
  - support@crashlog.io
@@ -111,7 +111,6 @@ files:
111
111
  - lib/crash_log/backtrace.rb
112
112
  - lib/crash_log/backtrace/line.rb
113
113
  - lib/crash_log/backtrace/line_cache.rb
114
- - lib/crash_log/configuration.bak.rb
115
114
  - lib/crash_log/configuration.rb
116
115
  - lib/crash_log/logging.rb
117
116
  - lib/crash_log/payload.rb
@@ -128,6 +127,7 @@ files:
128
127
  - lib/crashlog.rb
129
128
  - lib/faraday/request/hmac_authentication.rb
130
129
  - lib/rails/generators/crashlog/crashlog_generator.rb
130
+ - lib/tasks/crash_log.rake
131
131
  - rails/init.rb
132
132
  - script/integration_test
133
133
  - spec/crash_log/backtrace_spec.rb
@@ -200,7 +200,7 @@ rubyforge_project:
200
200
  rubygems_version: 1.8.15
201
201
  signing_key:
202
202
  specification_version: 3
203
- summary: CrashLog is an exception handler for production applications
203
+ summary: CrashLog is an exception handler for ambitious applications
204
204
  test_files:
205
205
  - spec/crash_log/backtrace_spec.rb
206
206
  - spec/crash_log/configuration_spec.rb
@@ -1,199 +0,0 @@
1
- module CrashLog
2
- class Configuration
3
-
4
- DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze
5
-
6
- DEFAULT_BACKTRACE_FILTERS = [
7
- lambda { |line|
8
- if defined?(CrashLog.configuration.project_root) &&
9
- CrashLog.configuration.project_root.to_s != ''
10
- line.sub(/#{CrashLog.configuration.project_root}/, "[PROJECT_ROOT]")
11
- else
12
- line
13
- end
14
- },
15
- lambda { |line| line.gsub(/^\.\//, "") },
16
- lambda { |line|
17
- if defined?(Gem)
18
- Gem.path.inject(line) do |line, path|
19
- line.gsub(/#{path}/, "[GEM_ROOT]")
20
- end
21
- end
22
- },
23
- lambda { |line| line if line !~ %r{lib/crash_log} }
24
- ].freeze
25
-
26
- ENVIRONMENT_FILTERS = []
27
-
28
- IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
29
- 'ActionController::RoutingError',
30
- 'ActionController::InvalidAuthenticityToken',
31
- 'CGI::Session::CookieStore::TamperedWithCookie',
32
- 'ActionController::UnknownAction',
33
- 'AbstractController::ActionNotFound',
34
- 'Mongoid::Errors::DocumentNotFound']
35
-
36
- # The default logging device
37
- #
38
- # This will be set to Rails.logger automatically if using Rails,
39
- # otherwise it defaults to STDOUT.
40
- attr_accessor :logger
41
-
42
- # The API key to authenticate this project with CrashLog
43
- #
44
- # Get this from your projects configuration page within http://CrashLog.io
45
- attr_accessor :api_key
46
-
47
- # Stages (environments) which we consider to be in a production environment
48
- # and thus you want to be sent notifications for.
49
- attr_accessor :release_stages
50
-
51
- # The name of the current stage
52
- attr_reader :stage
53
-
54
- # Project Root directory
55
- attr_accessor :project_root
56
- alias :root :project_root
57
- alias :root= :project_root=
58
-
59
- # If set, this will serialize the object returned by sending this key to
60
- # the controller context. You can use this to send user data CrashLog to
61
- # correlate errors with users to give you more advanced data about directly
62
- # who was affected.
63
- #
64
- # All user data is stored encrypted for security and always remains your
65
- # property.
66
- attr_accessor :user_context_key
67
-
68
- # Reporter configuration options
69
- #
70
- # Host to send exceptions to. Default: crashlog.io
71
- attr_accessor :host
72
-
73
- # Port to use for http connections. 80 or 443 by default.
74
- attr_writer :port
75
-
76
- def port
77
- if @port
78
- @port
79
- else
80
- secure? ? 443 : 80
81
- end
82
- end
83
-
84
- # HTTP transfer scheme, default: https
85
- attr_accessor :scheme
86
-
87
- # API endpoint to context for notifications. Default /notify
88
- attr_accessor :endpoint
89
-
90
- # The faraday adapter to use to make the connection.
91
- #
92
- # Possible values are:
93
- # - :test
94
- # - :net_http
95
- # - :net_http_persistent
96
- # - :typhoeus
97
- # - :patron
98
- # - :em_synchrony
99
- # - :em_http
100
- # - :excon
101
- # - :rack
102
- # - :httpclient
103
- #
104
- # Possible performance gains can be made by using the em based adapters if
105
- # your application supports this architecture.
106
- #
107
- # Default: net_http
108
- attr_accessor :adapter
109
-
110
- # Reader for Array of ignored error class names
111
- attr_reader :ignore
112
-
113
- attr_reader :announce_endpoint, :announce
114
-
115
- # Send context lines for backtrace.
116
- #
117
- # Takes an integer of the number of lines, set to false or nil to disable.
118
- attr_accessor :context_lines
119
-
120
- # Environment variables to discard from ENV.
121
- attr_accessor :environment_filters
122
-
123
- # Framework name
124
- attr_accessor :framework
125
-
126
- attr_accessor :dry_run
127
-
128
- attr_accessor :http_read_timeout, :http_open_timeout
129
-
130
- def initialize
131
- @dry_run = false
132
- @secure = true
133
- @use_system_ssl_cert_chain= false
134
- @host = 'crashlog.io'
135
- @http_open_timeout = 5
136
- @http_read_timeout = 2
137
- @adapter = :net_http
138
- @params_filters = DEFAULT_PARAMS_FILTERS.dup
139
- @backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup
140
- @environment_filters = ENVIRONMENT_FILTERS.dup
141
- @ignore_by_filters = []
142
- @ignore = IGNORE_DEFAULT.dup
143
- @release_stages = %w(production staging)
144
- @notifier_version = CrashLog::VERSION
145
- @notifier_url = 'https://github.com/ivanvanderbyl/crashlog'
146
- @framework = 'Standalone'
147
- @stage = 'development'
148
- @host = 'stdin.crashlog.io'
149
- @port = nil
150
- @scheme = port.eql?(443) ? 'https' : 'http'
151
- @endpoint = '/notify'
152
- @announce = true
153
- @announce_endpoint = '/announce'
154
- @context_lines = 5
155
- @framework = 'Standalone'
156
- end
157
-
158
- def release_stage?
159
- @release_stages.include?(stage)
160
- end
161
-
162
- def stage=(name)
163
- @stage = name.downcase.strip
164
- end
165
-
166
- # Is this configuration valid for sending exceptions to CrashLog
167
- #
168
- # Returns true if all required keys are provided, otherwise false
169
- def valid?
170
- [:api_key, :host, :port].all? do |key|
171
- !__send__(key).nil?
172
- end
173
- end
174
-
175
- def ignored?(exception)
176
- ignore.include?(error_class(exception))
177
- end
178
-
179
- def secure?
180
- scheme == 'https'
181
- end
182
-
183
- # Hash like accessor
184
- def [](key)
185
- if self.respond_to?(key)
186
- self.__send__(key)
187
- end
188
- end
189
-
190
- private
191
-
192
- def error_class(exception)
193
- # The "Class" check is for some strange exceptions like Timeout::Error
194
- # which throw the error class instead of an instance
195
- (exception.is_a? Class) ? exception.name : exception.class.name
196
- end
197
-
198
- end
199
- end