crashlog 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +5 -5
- data/README.md +5 -1
- data/crashlog.gemspec +2 -2
- data/generators/crashlog/USAGE +15 -0
- data/generators/crashlog/templates/initializer.rb +93 -0
- data/lib/crash_log/configuration.rb +3 -1
- data/lib/crash_log/reporter.rb +29 -6
- data/lib/crash_log/version.rb +1 -1
- data/lib/rails/generators/crashlog/crashlog_generator.rb +22 -18
- data/script/integration_test +4 -2
- metadata +20 -19
data/Gemfile.lock
CHANGED
@@ -8,13 +8,13 @@ GIT
|
|
8
8
|
PATH
|
9
9
|
remote: .
|
10
10
|
specs:
|
11
|
-
crashlog (1.0.
|
11
|
+
crashlog (1.0.4)
|
12
12
|
crashlog-auth-hmac (~> 1.1.6)
|
13
13
|
faraday (~> 0.8.4)
|
14
14
|
hashr
|
15
15
|
json
|
16
|
-
multi_json (
|
17
|
-
rabl (>= 0.6.
|
16
|
+
multi_json (>= 1.1.0)
|
17
|
+
rabl (>= 0.6.13)
|
18
18
|
uuid
|
19
19
|
|
20
20
|
GEM
|
@@ -50,9 +50,9 @@ GEM
|
|
50
50
|
rb-inotify (~> 0.8.8)
|
51
51
|
macaddr (1.6.1)
|
52
52
|
systemu (~> 2.5.0)
|
53
|
-
multi_json (1.3.
|
53
|
+
multi_json (1.3.7)
|
54
54
|
multipart-post (1.1.5)
|
55
|
-
rabl (0.7.
|
55
|
+
rabl (0.7.6)
|
56
56
|
activesupport (>= 2.3.14)
|
57
57
|
multi_json (~> 1.0)
|
58
58
|
rack (1.4.1)
|
data/README.md
CHANGED
data/crashlog.gemspec
CHANGED
@@ -16,9 +16,9 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = CrashLog::VERSION
|
17
17
|
|
18
18
|
gem.add_dependency("faraday", '~> 0.8.4')
|
19
|
-
gem.add_dependency("multi_json", '
|
19
|
+
gem.add_dependency("multi_json", '>= 1.1.0')
|
20
20
|
gem.add_dependency("crashlog-auth-hmac", '~> 1.1.6')
|
21
|
-
gem.add_dependency("rabl", '>= 0.6.
|
21
|
+
gem.add_dependency("rabl", '>= 0.6.13')
|
22
22
|
gem.add_dependency("uuid")
|
23
23
|
gem.add_dependency("hashr")
|
24
24
|
gem.add_dependency("json")
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Description:
|
2
|
+
Generates an initializer in config/initializers and
|
3
|
+
runs `rake crashlog:test` to ensure you're able to send exceptions.
|
4
|
+
|
5
|
+
Example:
|
6
|
+
|
7
|
+
rails generate crashlog KEY:SECRET
|
8
|
+
|
9
|
+
Help:
|
10
|
+
If you receive an error during the connection test it is most likely that your
|
11
|
+
KEY or SECRET are incorrect.
|
12
|
+
|
13
|
+
If you continue to have issues, or you just want to say hi, send
|
14
|
+
an email to support@crashlog.io
|
15
|
+
|
@@ -1,7 +1,100 @@
|
|
1
|
+
# Use this hook to configure how you want CrashLog to behave in your application.
|
2
|
+
|
3
|
+
# If you're using Bundler.setup instead of Bundler.require you will need to
|
4
|
+
# require CrashLog explicitly:
|
5
|
+
#
|
6
|
+
# require 'crashlog'
|
7
|
+
|
1
8
|
<% if Rails::VERSION::MAJOR < 3 && Rails::VERSION::MINOR < 2 -%>
|
2
9
|
require 'crash_log/rails'
|
3
10
|
<% end -%>
|
4
11
|
CrashLog.configure do |config|
|
12
|
+
# ==> Authentication credentials
|
13
|
+
# Enter your authentication credentials here. You can get these from the
|
14
|
+
# 'Authentication' tab of your project in the CrashLog UI https://crashlog.io
|
5
15
|
config.api_key = <%= api_key_expression %>
|
6
16
|
config.secret = <%= secret_expression %>
|
17
|
+
|
18
|
+
# ==> Ignored exceptions
|
19
|
+
# By default we ignore:
|
20
|
+
# - ActiveRecord::RecordNotFound,
|
21
|
+
# - ActionController::RoutingError,
|
22
|
+
# - ActionController::InvalidAuthenticityToken
|
23
|
+
# - CGI::Session::CookieStore::TamperedWithCookie
|
24
|
+
# - ActionController::UnknownAction
|
25
|
+
# - AbstractController::ActionNotFound
|
26
|
+
# - Mongoid::Errors::DocumentNotFound
|
27
|
+
#
|
28
|
+
# Generally most of these result in a 404 being sent back to the client,
|
29
|
+
# as such they can create a lot of noise.
|
30
|
+
#
|
31
|
+
# To disable any of them uncomment and update this line:
|
32
|
+
# config.ignore -= %w(ActionController::RoutingError)
|
33
|
+
# or, don't ignore anything:
|
34
|
+
# config.ignore = []
|
35
|
+
|
36
|
+
# ==> Release stages
|
37
|
+
# Configure the stages that you can to capture exceptions in. By default
|
38
|
+
# we only activate in production and staging.
|
39
|
+
#
|
40
|
+
# When your application starts it will set the current stage to the name
|
41
|
+
# of the current environment.
|
42
|
+
#
|
43
|
+
# Add another stage:
|
44
|
+
# config.release_stages << 'integration'
|
45
|
+
|
46
|
+
# ==> HTTP Adapter
|
47
|
+
# Change adapter used to talk to CrashLog collection endpoints.
|
48
|
+
# Available options:
|
49
|
+
#
|
50
|
+
# - :test - Test adapter, used for running tests.
|
51
|
+
# - :net_http - (Default) Ruby Net::HTTP
|
52
|
+
# - :net_http_persistent - Ruby Net::HTTP in persistent mode
|
53
|
+
# - :typhoeus - High performance parallel HTTP adapter
|
54
|
+
# - :patron - Ruby HTTP client based on libcurl
|
55
|
+
# - :em_synchrony - Asynchronous EventMachine based adapter
|
56
|
+
# - :em_http - Pretty much the same of above.
|
57
|
+
# - :excon - The wonderful adapter used by Fog.
|
58
|
+
# - :rack - Rack adapter
|
59
|
+
# - :httpclient - 'httpclient' gives something like the
|
60
|
+
# functionality of libwww-perl (LWP) in Ruby
|
61
|
+
#
|
62
|
+
# config.adapter = :net_http
|
63
|
+
|
64
|
+
# ==> Timeouts
|
65
|
+
# Increase these if you experience connection issues.
|
66
|
+
#
|
67
|
+
# Timeout for connecting to CrashLog collector interface (in seconds)
|
68
|
+
# config.http_open_timeout = 5
|
69
|
+
#
|
70
|
+
# Timeout for actually sending the exeption payload (in seconds)
|
71
|
+
# config.http_read_timeout = 2
|
72
|
+
|
73
|
+
# ==> Environment filters
|
74
|
+
# Filters for filtering ENV[] which gets sent with each exception.
|
75
|
+
# Refer to https://github.com/crashlog/crashlog/blob/master/lib/crash_log/configuration.rb
|
76
|
+
#
|
77
|
+
# config.environment_filters += [/SOMETHING_SECRET/]
|
78
|
+
|
79
|
+
# ==> Backtrace filters
|
80
|
+
# Standard backtrace filters (processed by every line)
|
81
|
+
# config.backtrace_filters += lambda { |line| }
|
82
|
+
|
83
|
+
# ==> JSON Engine
|
84
|
+
# If you have trouble encoding or decoding, or you're using a specific JSON
|
85
|
+
# engine in your app, set it here.
|
86
|
+
#
|
87
|
+
# We use MultiJson behind the scenes so any option available to MultiJson can
|
88
|
+
# be set.
|
89
|
+
# config.json_parser = :yajl
|
90
|
+
|
91
|
+
# ==> SSL certificate chain
|
92
|
+
# On some platforms the SSL implementation available to Ruby doesn't include
|
93
|
+
# our SSL providers certificate in the default chain. Because of this we package
|
94
|
+
# our own certificate chain and use if by default. If you want to use the
|
95
|
+
# system chain, set this to false.
|
96
|
+
# config.use_system_ssl_cert_chain = false
|
97
|
+
|
98
|
+
# ==> Advanced options
|
99
|
+
# Refer to https://github.com/crashlog/crashlog/blob/master/lib/crash_log/configuration.rb
|
7
100
|
end
|
@@ -156,7 +156,9 @@ module CrashLog
|
|
156
156
|
:service_name => 'CrashLog',
|
157
157
|
|
158
158
|
# MultiJson adapter
|
159
|
-
:json_parser => MultiJson.default_adapter
|
159
|
+
:json_parser => MultiJson.respond_to?(:default_adapter) ?
|
160
|
+
MultiJson.default_adapter :
|
161
|
+
MultiJson.default_engine,
|
160
162
|
|
161
163
|
# Development mode
|
162
164
|
# When enabled we don't swallow internal exceptions.
|
data/lib/crash_log/reporter.rb
CHANGED
@@ -19,10 +19,10 @@ module CrashLog
|
|
19
19
|
@announce_endpoint = config.announce == true ?
|
20
20
|
config.announce_endpoint : nil
|
21
21
|
|
22
|
-
# Old versions of MultiJson don't support #use.
|
23
|
-
# TODO: Figure out what they do support. IV.
|
24
22
|
if MultiJson.respond_to?(:use)
|
25
23
|
MultiJson.use(config.json_parser || MultiJson.default_adapter)
|
24
|
+
elsif MultiJson.respond_to?(:engine=)
|
25
|
+
MultiJson.engine = (config.json_parser || MultiJson.default_engine)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -31,7 +31,7 @@ module CrashLog
|
|
31
31
|
|
32
32
|
# TODO: Move this to Payload.
|
33
33
|
payload[:data] = CrashLog::Helpers.cleanup_obj(payload[:data])
|
34
|
-
payload_string =
|
34
|
+
payload_string = encode({:payload => payload})
|
35
35
|
|
36
36
|
# Useful to make sure we're successfully capturing the right data
|
37
37
|
debug(payload.inspect) if config.development_mode?
|
@@ -50,9 +50,9 @@ module CrashLog
|
|
50
50
|
return if dry_run?
|
51
51
|
return "Unknown application" unless announce_endpoint
|
52
52
|
|
53
|
-
response = post(config.announce_endpoint,
|
53
|
+
response = post(config.announce_endpoint, encode({:payload => identification_hash}))
|
54
54
|
if response.status == 201
|
55
|
-
|
55
|
+
decode(response.body).symbolize_keys.fetch(:application_name, 'Default')
|
56
56
|
else
|
57
57
|
nil
|
58
58
|
end
|
@@ -63,7 +63,7 @@ module CrashLog
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def report_result(body)
|
66
|
-
@result =
|
66
|
+
@result = decode(body).symbolize_keys
|
67
67
|
end
|
68
68
|
|
69
69
|
def url
|
@@ -117,5 +117,28 @@ module CrashLog
|
|
117
117
|
def adapter
|
118
118
|
config.adapter
|
119
119
|
end
|
120
|
+
|
121
|
+
# FIXME: This is some seriously annoying shit.
|
122
|
+
# MultiJson should not have deprecated its old API and we wouldn't need
|
123
|
+
# to do this.
|
124
|
+
def encode(object)
|
125
|
+
if MultiJson.respond_to?(:dump)
|
126
|
+
# MultiJson >= 1.3
|
127
|
+
MultiJson.dump(object)
|
128
|
+
elsif MultiJson.respond_to?(:encode)
|
129
|
+
# MultiJson < 1.3
|
130
|
+
MultiJson.encode(object)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def decode(string, options = {})
|
135
|
+
if MultiJson.respond_to?(:load)
|
136
|
+
# MultiJson >= 1.3
|
137
|
+
MultiJson.load(string, options)
|
138
|
+
elsif MultiJson.respond_to?(:decode)
|
139
|
+
# MultiJson < 1.3
|
140
|
+
MultiJson.decode(string, options)
|
141
|
+
end
|
142
|
+
end
|
120
143
|
end
|
121
144
|
end
|
data/lib/crash_log/version.rb
CHANGED
@@ -1,37 +1,41 @@
|
|
1
1
|
require 'rails/generators'
|
2
2
|
|
3
3
|
class CrashlogGenerator < Rails::Generators::Base
|
4
|
-
|
5
|
-
class_option :
|
6
|
-
|
7
|
-
|
8
|
-
def self.source_root
|
9
|
-
@_crashlog_source_root ||= File.expand_path("../../../../../generators/crashlog/templates", __FILE__)
|
10
|
-
end
|
4
|
+
argument :api_key, :type => :string
|
5
|
+
class_option :force, :aliases => "-f", :type => :boolean, :desc => "Replace existing crashlog.rb file"
|
6
|
+
source_root File.expand_path("../../../../../generators/crashlog/templates", __FILE__)
|
11
7
|
|
12
8
|
def install
|
13
|
-
|
9
|
+
ensure_api_key_is_valid_format
|
14
10
|
generate_initializer unless api_key_configured?
|
15
11
|
test_crashlog
|
16
12
|
end
|
17
13
|
|
18
14
|
private
|
19
15
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
puts "Must pass --api-key and --secret or create config/initializers/crashlog.rb"
|
25
|
-
exit
|
16
|
+
def ensure_api_key_is_valid_format
|
17
|
+
unless api_key_pair_provided?
|
18
|
+
puts "API_KEY does not match required format: <KEY>:<SECRET>"
|
19
|
+
exit(1)
|
26
20
|
end
|
27
21
|
end
|
28
22
|
|
23
|
+
def api_key_pair_provided?
|
24
|
+
!!(self.api_key =~ /^(\h){8}-(\h){4}-(\h){4}-(\h){4}-(\h){12}\:\w+$/)
|
25
|
+
end
|
26
|
+
|
27
|
+
def api_key_pair
|
28
|
+
/(?<api_key>^(\h){8}-(\h){4}-(\h){4}-(\h){4}-(\h){12})\:(?<secret>\w+)$/.match(self.api_key)
|
29
|
+
end
|
30
|
+
|
29
31
|
def api_key_expression
|
30
|
-
|
32
|
+
api_key = api_key_pair[:api_key]
|
33
|
+
"'#{api_key}'"
|
31
34
|
end
|
32
35
|
|
33
36
|
def secret_expression
|
34
|
-
|
37
|
+
secret = api_key_pair[:secret]
|
38
|
+
"'#{secret}'"
|
35
39
|
end
|
36
40
|
|
37
41
|
def generate_initializer
|
@@ -39,11 +43,11 @@ class CrashlogGenerator < Rails::Generators::Base
|
|
39
43
|
end
|
40
44
|
|
41
45
|
def api_key_configured?
|
46
|
+
return false if options[:force]
|
42
47
|
File.exists?('config/initializers/crashlog.rb')
|
43
48
|
end
|
44
49
|
|
45
50
|
def test_crashlog
|
46
|
-
|
51
|
+
run("rake crashlog:test")
|
47
52
|
end
|
48
53
|
end
|
49
|
-
|
data/script/integration_test
CHANGED
@@ -14,7 +14,9 @@ require File.expand_path('../../rails/init', __FILE__)
|
|
14
14
|
|
15
15
|
fail "Please supply an API Key as the first argument" if ARGV.empty?
|
16
16
|
|
17
|
-
|
17
|
+
staging = ARGV.find { |arg| arg == '--staging' }
|
18
|
+
host = ARGV.find { |arg| arg =~ /^http/ }
|
19
|
+
|
18
20
|
host = "https://stdin.crashlog.io" if host.blank?
|
19
21
|
|
20
22
|
class SimulatedExceptionRaiser
|
@@ -39,7 +41,7 @@ CrashLog.configure(true) do |config|
|
|
39
41
|
config.host = URI.parse(host).host
|
40
42
|
config.port = URI.parse(host).port
|
41
43
|
config.development_mode = true
|
42
|
-
|
44
|
+
config.service_name = 'Staging' if staging
|
43
45
|
end
|
44
46
|
|
45
47
|
secure = CrashLog.configuration.secure?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crashlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
16
|
-
requirement: &
|
16
|
+
requirement: &70229446276380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,21 +21,21 @@ dependencies:
|
|
21
21
|
version: 0.8.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70229446276380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: multi_json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70229446274140 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
|
-
- -
|
30
|
+
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.
|
32
|
+
version: 1.1.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70229446274140
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: crashlog-auth-hmac
|
38
|
-
requirement: &
|
38
|
+
requirement: &70229446273460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,21 +43,21 @@ dependencies:
|
|
43
43
|
version: 1.1.6
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70229446273460
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rabl
|
49
|
-
requirement: &
|
49
|
+
requirement: &70229446272540 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.6.
|
54
|
+
version: 0.6.13
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70229446272540
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: uuid
|
60
|
-
requirement: &
|
60
|
+
requirement: &70229446271620 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70229446271620
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: hashr
|
71
|
-
requirement: &
|
71
|
+
requirement: &70229446287340 !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: *
|
79
|
+
version_requirements: *70229446287340
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: json
|
82
|
-
requirement: &
|
82
|
+
requirement: &70229446286920 !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: *
|
90
|
+
version_requirements: *70229446286920
|
91
91
|
description: CrashLog Exception reporter
|
92
92
|
email:
|
93
93
|
- support@crashlog.io
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- README.md
|
106
106
|
- Rakefile
|
107
107
|
- crashlog.gemspec
|
108
|
+
- generators/crashlog/USAGE
|
108
109
|
- generators/crashlog/templates/initializer.rb
|
109
110
|
- install.rb
|
110
111
|
- lib/core_ext/hash/keys.rb
|