crashlog 1.0.7 → 1.1.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/.travis.yml +19 -8
  2. data/Appraisals +25 -0
  3. data/Gemfile +4 -4
  4. data/Gemfile.lock +54 -13
  5. data/README.md +1 -1
  6. data/Rakefile +4 -0
  7. data/gemfiles/rails_2_3.gemfile +17 -0
  8. data/gemfiles/rails_2_3.gemfile.lock +111 -0
  9. data/gemfiles/rails_3_0.gemfile +17 -0
  10. data/gemfiles/rails_3_0.gemfile.lock +159 -0
  11. data/gemfiles/rails_3_1.gemfile +17 -0
  12. data/gemfiles/rails_3_1.gemfile.lock +169 -0
  13. data/gemfiles/rails_3_2.gemfile +17 -0
  14. data/gemfiles/rails_3_2.gemfile.lock +168 -0
  15. data/lib/crash_log.rb +2 -0
  16. data/lib/crash_log/payload.rb +2 -1
  17. data/lib/crash_log/rails/controller_methods.rb +98 -18
  18. data/lib/crash_log/rails/middleware/debug_exception_catcher.rb +6 -4
  19. data/lib/crash_log/railtie.rb +5 -4
  20. data/lib/crash_log/reporter.rb +4 -4
  21. data/lib/crash_log/sidekiq.rb +18 -0
  22. data/lib/crash_log/version.rb +1 -1
  23. data/spec/crash_log/initializer_spec.rb +39 -39
  24. data/spec/crash_log/payload_spec.rb +2 -0
  25. data/spec/dummy_rails_2/README +243 -0
  26. data/spec/dummy_rails_2/Rakefile +10 -0
  27. data/spec/dummy_rails_2/app/controllers/application_controller.rb +14 -0
  28. data/spec/dummy_rails_2/app/controllers/welcome_controller.rb +13 -0
  29. data/spec/dummy_rails_2/app/helpers/application_helper.rb +3 -0
  30. data/spec/dummy_rails_2/app/helpers/welcome_helper.rb +3 -0
  31. data/spec/dummy_rails_2/app/models/user.rb +2 -0
  32. data/spec/dummy_rails_2/config/boot.rb +114 -0
  33. data/spec/dummy_rails_2/config/environment.rb +41 -0
  34. data/spec/dummy_rails_2/config/environments/test.rb +28 -0
  35. data/spec/dummy_rails_2/config/initializers/backtrace_silencers.rb +7 -0
  36. data/spec/dummy_rails_2/config/initializers/cookie_verification_secret.rb +7 -0
  37. data/spec/{dummy → dummy_rails_2}/config/initializers/crashlog.rb +0 -0
  38. data/spec/dummy_rails_2/config/initializers/inflections.rb +10 -0
  39. data/spec/{dummy → dummy_rails_2}/config/initializers/mime_types.rb +0 -0
  40. data/spec/dummy_rails_2/config/initializers/new_rails_defaults.rb +13 -0
  41. data/spec/dummy_rails_2/config/initializers/session_store.rb +15 -0
  42. data/spec/dummy_rails_2/config/locales/en.yml +5 -0
  43. data/spec/dummy_rails_2/config/routes.rb +38 -0
  44. data/spec/dummy_rails_2/db/seeds.rb +7 -0
  45. data/spec/{dummy/app/mailers/.gitkeep → dummy_rails_2/log/development.log} +0 -0
  46. data/spec/{dummy/app/models/.gitkeep → dummy_rails_2/log/production.log} +0 -0
  47. data/spec/{dummy/lib/assets/.gitkeep → dummy_rails_2/log/server.log} +0 -0
  48. data/spec/dummy_rails_3/.gitignore +4 -0
  49. data/spec/dummy_rails_3/Gemfile +31 -0
  50. data/spec/dummy_rails_3/README +256 -0
  51. data/spec/dummy_rails_3/Rakefile +7 -0
  52. data/spec/dummy_rails_3/app/controllers/application_controller.rb +7 -0
  53. data/spec/dummy_rails_3/app/controllers/welcome_controller.rb +14 -0
  54. data/spec/{dummy → dummy_rails_3}/app/helpers/application_helper.rb +0 -0
  55. data/spec/dummy_rails_3/app/models/user.rb +3 -0
  56. data/spec/dummy_rails_3/app/views/layouts/application.html.erb +14 -0
  57. data/spec/{dummy → dummy_rails_3}/config.ru +0 -0
  58. data/spec/dummy_rails_3/config/application.rb +52 -0
  59. data/spec/dummy_rails_3/config/boot.rb +6 -0
  60. data/spec/{dummy → dummy_rails_3}/config/environment.rb +0 -0
  61. data/spec/dummy_rails_3/config/environments/development.rb +26 -0
  62. data/spec/dummy_rails_3/config/environments/production.rb +49 -0
  63. data/spec/dummy_rails_3/config/environments/test.rb +35 -0
  64. data/spec/{dummy → dummy_rails_3}/config/initializers/backtrace_silencers.rb +0 -0
  65. data/spec/dummy_rails_3/config/initializers/crashlog.rb +8 -0
  66. data/spec/dummy_rails_3/config/initializers/inflections.rb +10 -0
  67. data/spec/dummy_rails_3/config/initializers/mime_types.rb +5 -0
  68. data/spec/dummy_rails_3/config/initializers/secret_token.rb +7 -0
  69. data/spec/{dummy → dummy_rails_3}/config/initializers/session_store.rb +0 -0
  70. data/spec/dummy_rails_3/config/locales/en.yml +5 -0
  71. data/spec/dummy_rails_3/config/routes.rb +5 -0
  72. data/spec/dummy_rails_3/db/seeds.rb +7 -0
  73. data/spec/{dummy → dummy_rails_3_plus}/README.rdoc +0 -0
  74. data/spec/{dummy → dummy_rails_3_plus}/Rakefile +0 -0
  75. data/spec/{dummy → dummy_rails_3_plus}/app/assets/javascripts/application.js +0 -0
  76. data/spec/{dummy → dummy_rails_3_plus}/app/assets/stylesheets/application.css +0 -0
  77. data/spec/dummy_rails_3_plus/app/controllers/application_controller.rb +7 -0
  78. data/spec/{dummy → dummy_rails_3_plus}/app/controllers/break_controller.rb +0 -0
  79. data/spec/dummy_rails_3_plus/app/controllers/welcome_controller.rb +13 -0
  80. data/spec/dummy_rails_3_plus/app/helpers/application_helper.rb +2 -0
  81. data/spec/{dummy/log → dummy_rails_3_plus/app/mailers}/.gitkeep +0 -0
  82. data/spec/{dummy/public/favicon.ico → dummy_rails_3_plus/app/models/.gitkeep} +0 -0
  83. data/spec/{dummy → dummy_rails_3_plus}/app/models/current_user.rb +0 -0
  84. data/spec/{dummy → dummy_rails_3_plus}/app/views/layouts/application.html.erb +0 -0
  85. data/spec/dummy_rails_3_plus/config.ru +4 -0
  86. data/spec/{dummy → dummy_rails_3_plus}/config/application.rb +3 -3
  87. data/spec/{dummy → dummy_rails_3_plus}/config/boot.rb +0 -0
  88. data/spec/dummy_rails_3_plus/config/environment.rb +5 -0
  89. data/spec/{dummy → dummy_rails_3_plus}/config/environments/development.rb +0 -0
  90. data/spec/{dummy → dummy_rails_3_plus}/config/environments/production.rb +0 -0
  91. data/spec/{dummy → dummy_rails_3_plus}/config/environments/test.rb +2 -2
  92. data/spec/dummy_rails_3_plus/config/initializers/backtrace_silencers.rb +7 -0
  93. data/spec/dummy_rails_3_plus/config/initializers/crashlog.rb +7 -0
  94. data/spec/{dummy → dummy_rails_3_plus}/config/initializers/inflections.rb +0 -0
  95. data/spec/dummy_rails_3_plus/config/initializers/mime_types.rb +5 -0
  96. data/spec/{dummy → dummy_rails_3_plus}/config/initializers/secret_token.rb +0 -0
  97. data/spec/dummy_rails_3_plus/config/initializers/session_store.rb +8 -0
  98. data/spec/{dummy → dummy_rails_3_plus}/config/initializers/wrap_parameters.rb +0 -0
  99. data/spec/dummy_rails_3_plus/config/routes.rb +5 -0
  100. data/spec/dummy_rails_3_plus/lib/assets/.gitkeep +0 -0
  101. data/spec/dummy_rails_3_plus/log/.gitkeep +0 -0
  102. data/spec/dummy_rails_3_plus/log/development.log +13209 -0
  103. data/spec/{dummy → dummy_rails_3_plus}/public/404.html +0 -0
  104. data/spec/{dummy → dummy_rails_3_plus}/public/422.html +0 -0
  105. data/spec/{dummy → dummy_rails_3_plus}/public/500.html +0 -0
  106. data/spec/dummy_rails_3_plus/public/favicon.ico +0 -0
  107. data/spec/{dummy → dummy_rails_3_plus}/script/rails +0 -0
  108. data/spec/rails/action_controller_spec.rb +85 -0
  109. data/spec/rails/rails_2_controller_spec.rb +87 -0
  110. data/spec/rails_spec_helper.rb +42 -0
  111. data/spec/requests/rails_controller_rescue_spec.rb +6 -6
  112. data/spec/spec_helper.rb +0 -4
  113. metadata +204 -87
  114. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  115. data/spec/dummy/config/database.yml +0 -44
  116. data/spec/dummy/config/routes.rb +0 -7
@@ -0,0 +1,17 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source :rubygems
4
+
5
+ gem "rspec-rails"
6
+ gem "rspec"
7
+ gem "guard-rspec"
8
+ gem "uuid"
9
+ gem "json_spec"
10
+ gem "rake", "0.9.2"
11
+ gem "delorean"
12
+ gem "rack-test"
13
+ gem "simplecov", :platforms=>:mri_19
14
+ gem "appraisal"
15
+ gem "rails", "3.1.8"
16
+
17
+ gemspec :path=>"../"
@@ -0,0 +1,169 @@
1
+ PATH
2
+ remote: /Users/ivan/Dropbox/dev/ruby/crashlog-gem
3
+ specs:
4
+ crashlog (1.0.7)
5
+ crashlog-auth-hmac (>= 1.1.7)
6
+ faraday (~> 0.8.4)
7
+ hashr
8
+ json
9
+ multi_json (>= 1.1.0)
10
+ rabl (>= 0.6.13)
11
+ uuid
12
+
13
+ GEM
14
+ remote: http://rubygems.org/
15
+ specs:
16
+ actionmailer (3.1.8)
17
+ actionpack (= 3.1.8)
18
+ mail (~> 2.3.3)
19
+ actionpack (3.1.8)
20
+ activemodel (= 3.1.8)
21
+ activesupport (= 3.1.8)
22
+ builder (~> 3.0.0)
23
+ erubis (~> 2.7.0)
24
+ i18n (~> 0.6)
25
+ rack (~> 1.3.6)
26
+ rack-cache (~> 1.2)
27
+ rack-mount (~> 0.8.2)
28
+ rack-test (~> 0.6.1)
29
+ sprockets (~> 2.0.4)
30
+ activemodel (3.1.8)
31
+ activesupport (= 3.1.8)
32
+ builder (~> 3.0.0)
33
+ i18n (~> 0.6)
34
+ activerecord (3.1.8)
35
+ activemodel (= 3.1.8)
36
+ activesupport (= 3.1.8)
37
+ arel (~> 2.2.3)
38
+ tzinfo (~> 0.3.29)
39
+ activeresource (3.1.8)
40
+ activemodel (= 3.1.8)
41
+ activesupport (= 3.1.8)
42
+ activesupport (3.1.8)
43
+ multi_json (>= 1.0, < 1.3)
44
+ appraisal (0.5.1)
45
+ bundler
46
+ rake
47
+ arel (2.2.3)
48
+ builder (3.0.4)
49
+ chronic (0.8.0)
50
+ coderay (1.0.8)
51
+ crashlog-auth-hmac (1.1.7)
52
+ delorean (2.1.0)
53
+ chronic
54
+ diff-lcs (1.1.3)
55
+ erubis (2.7.0)
56
+ faraday (0.8.4)
57
+ multipart-post (~> 1.1)
58
+ guard (1.5.4)
59
+ listen (>= 0.4.2)
60
+ lumberjack (>= 1.0.2)
61
+ pry (>= 0.9.10)
62
+ thor (>= 0.14.6)
63
+ guard-rspec (2.3.1)
64
+ guard (>= 1.1)
65
+ rspec (~> 2.11)
66
+ hashr (0.0.22)
67
+ hike (1.2.1)
68
+ i18n (0.6.1)
69
+ json (1.7.5)
70
+ json_spec (1.1.0)
71
+ multi_json (~> 1.0)
72
+ rspec (~> 2.0)
73
+ listen (0.6.0)
74
+ lumberjack (1.0.2)
75
+ macaddr (1.6.1)
76
+ systemu (~> 2.5.0)
77
+ mail (2.3.3)
78
+ i18n (>= 0.4.0)
79
+ mime-types (~> 1.16)
80
+ treetop (~> 1.4.8)
81
+ method_source (0.8.1)
82
+ mime-types (1.19)
83
+ multi_json (1.2.0)
84
+ multipart-post (1.1.5)
85
+ polyglot (0.3.3)
86
+ pry (0.9.10)
87
+ coderay (~> 1.0.5)
88
+ method_source (~> 0.8)
89
+ slop (~> 3.3.1)
90
+ rabl (0.7.9)
91
+ activesupport (>= 2.3.14)
92
+ multi_json (~> 1.0)
93
+ rack (1.3.6)
94
+ rack-cache (1.2)
95
+ rack (>= 0.4)
96
+ rack-mount (0.8.3)
97
+ rack (>= 1.0.0)
98
+ rack-ssl (1.3.2)
99
+ rack
100
+ rack-test (0.6.2)
101
+ rack (>= 1.0)
102
+ rails (3.1.8)
103
+ actionmailer (= 3.1.8)
104
+ actionpack (= 3.1.8)
105
+ activerecord (= 3.1.8)
106
+ activeresource (= 3.1.8)
107
+ activesupport (= 3.1.8)
108
+ bundler (~> 1.0)
109
+ railties (= 3.1.8)
110
+ railties (3.1.8)
111
+ actionpack (= 3.1.8)
112
+ activesupport (= 3.1.8)
113
+ rack-ssl (~> 1.3.2)
114
+ rake (>= 0.8.7)
115
+ rdoc (~> 3.4)
116
+ thor (~> 0.14.6)
117
+ rake (0.9.2)
118
+ rdoc (3.12)
119
+ json (~> 1.4)
120
+ rspec (2.12.0)
121
+ rspec-core (~> 2.12.0)
122
+ rspec-expectations (~> 2.12.0)
123
+ rspec-mocks (~> 2.12.0)
124
+ rspec-core (2.12.1)
125
+ rspec-expectations (2.12.0)
126
+ diff-lcs (~> 1.1.3)
127
+ rspec-mocks (2.12.0)
128
+ rspec-rails (2.12.0)
129
+ actionpack (>= 3.0)
130
+ activesupport (>= 3.0)
131
+ railties (>= 3.0)
132
+ rspec-core (~> 2.12.0)
133
+ rspec-expectations (~> 2.12.0)
134
+ rspec-mocks (~> 2.12.0)
135
+ simplecov (0.7.1)
136
+ multi_json (~> 1.0)
137
+ simplecov-html (~> 0.7.1)
138
+ simplecov-html (0.7.1)
139
+ slop (3.3.3)
140
+ sprockets (2.0.4)
141
+ hike (~> 1.2)
142
+ rack (~> 1.0)
143
+ tilt (~> 1.1, != 1.3.0)
144
+ systemu (2.5.2)
145
+ thor (0.14.6)
146
+ tilt (1.3.3)
147
+ treetop (1.4.12)
148
+ polyglot
149
+ polyglot (>= 0.3.1)
150
+ tzinfo (0.3.35)
151
+ uuid (2.3.6)
152
+ macaddr (~> 1.0)
153
+
154
+ PLATFORMS
155
+ ruby
156
+
157
+ DEPENDENCIES
158
+ appraisal
159
+ crashlog!
160
+ delorean
161
+ guard-rspec
162
+ json_spec
163
+ rack-test
164
+ rails (= 3.1.8)
165
+ rake (= 0.9.2)
166
+ rspec
167
+ rspec-rails
168
+ simplecov
169
+ uuid
@@ -0,0 +1,17 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source :rubygems
4
+
5
+ gem "rspec-rails"
6
+ gem "rspec"
7
+ gem "guard-rspec"
8
+ gem "uuid"
9
+ gem "json_spec"
10
+ gem "rake", "0.9.2"
11
+ gem "delorean"
12
+ gem "rack-test"
13
+ gem "simplecov", :platforms=>:mri_19
14
+ gem "appraisal"
15
+ gem "rails", "3.2.9"
16
+
17
+ gemspec :path=>"../"
@@ -0,0 +1,168 @@
1
+ PATH
2
+ remote: /Users/ivan/Dropbox/dev/ruby/crashlog-gem
3
+ specs:
4
+ crashlog (1.0.7)
5
+ crashlog-auth-hmac (>= 1.1.7)
6
+ faraday (~> 0.8.4)
7
+ hashr
8
+ json
9
+ multi_json (>= 1.1.0)
10
+ rabl (>= 0.6.13)
11
+ uuid
12
+
13
+ GEM
14
+ remote: http://rubygems.org/
15
+ specs:
16
+ actionmailer (3.2.9)
17
+ actionpack (= 3.2.9)
18
+ mail (~> 2.4.4)
19
+ actionpack (3.2.9)
20
+ activemodel (= 3.2.9)
21
+ activesupport (= 3.2.9)
22
+ builder (~> 3.0.0)
23
+ erubis (~> 2.7.0)
24
+ journey (~> 1.0.4)
25
+ rack (~> 1.4.0)
26
+ rack-cache (~> 1.2)
27
+ rack-test (~> 0.6.1)
28
+ sprockets (~> 2.2.1)
29
+ activemodel (3.2.9)
30
+ activesupport (= 3.2.9)
31
+ builder (~> 3.0.0)
32
+ activerecord (3.2.9)
33
+ activemodel (= 3.2.9)
34
+ activesupport (= 3.2.9)
35
+ arel (~> 3.0.2)
36
+ tzinfo (~> 0.3.29)
37
+ activeresource (3.2.9)
38
+ activemodel (= 3.2.9)
39
+ activesupport (= 3.2.9)
40
+ activesupport (3.2.9)
41
+ i18n (~> 0.6)
42
+ multi_json (~> 1.0)
43
+ appraisal (0.5.1)
44
+ bundler
45
+ rake
46
+ arel (3.0.2)
47
+ builder (3.0.4)
48
+ chronic (0.8.0)
49
+ coderay (1.0.8)
50
+ crashlog-auth-hmac (1.1.7)
51
+ delorean (2.1.0)
52
+ chronic
53
+ diff-lcs (1.1.3)
54
+ erubis (2.7.0)
55
+ faraday (0.8.4)
56
+ multipart-post (~> 1.1)
57
+ guard (1.5.4)
58
+ listen (>= 0.4.2)
59
+ lumberjack (>= 1.0.2)
60
+ pry (>= 0.9.10)
61
+ thor (>= 0.14.6)
62
+ guard-rspec (2.3.1)
63
+ guard (>= 1.1)
64
+ rspec (~> 2.11)
65
+ hashr (0.0.22)
66
+ hike (1.2.1)
67
+ i18n (0.6.1)
68
+ journey (1.0.4)
69
+ json (1.7.5)
70
+ json_spec (1.1.0)
71
+ multi_json (~> 1.0)
72
+ rspec (~> 2.0)
73
+ listen (0.6.0)
74
+ lumberjack (1.0.2)
75
+ macaddr (1.6.1)
76
+ systemu (~> 2.5.0)
77
+ mail (2.4.4)
78
+ i18n (>= 0.4.0)
79
+ mime-types (~> 1.16)
80
+ treetop (~> 1.4.8)
81
+ method_source (0.8.1)
82
+ mime-types (1.19)
83
+ multi_json (1.5.0)
84
+ multipart-post (1.1.5)
85
+ polyglot (0.3.3)
86
+ pry (0.9.10)
87
+ coderay (~> 1.0.5)
88
+ method_source (~> 0.8)
89
+ slop (~> 3.3.1)
90
+ rabl (0.7.9)
91
+ activesupport (>= 2.3.14)
92
+ multi_json (~> 1.0)
93
+ rack (1.4.1)
94
+ rack-cache (1.2)
95
+ rack (>= 0.4)
96
+ rack-ssl (1.3.2)
97
+ rack
98
+ rack-test (0.6.2)
99
+ rack (>= 1.0)
100
+ rails (3.2.9)
101
+ actionmailer (= 3.2.9)
102
+ actionpack (= 3.2.9)
103
+ activerecord (= 3.2.9)
104
+ activeresource (= 3.2.9)
105
+ activesupport (= 3.2.9)
106
+ bundler (~> 1.0)
107
+ railties (= 3.2.9)
108
+ railties (3.2.9)
109
+ actionpack (= 3.2.9)
110
+ activesupport (= 3.2.9)
111
+ rack-ssl (~> 1.3.2)
112
+ rake (>= 0.8.7)
113
+ rdoc (~> 3.4)
114
+ thor (>= 0.14.6, < 2.0)
115
+ rake (0.9.2)
116
+ rdoc (3.12)
117
+ json (~> 1.4)
118
+ rspec (2.12.0)
119
+ rspec-core (~> 2.12.0)
120
+ rspec-expectations (~> 2.12.0)
121
+ rspec-mocks (~> 2.12.0)
122
+ rspec-core (2.12.1)
123
+ rspec-expectations (2.12.0)
124
+ diff-lcs (~> 1.1.3)
125
+ rspec-mocks (2.12.0)
126
+ rspec-rails (2.12.0)
127
+ actionpack (>= 3.0)
128
+ activesupport (>= 3.0)
129
+ railties (>= 3.0)
130
+ rspec-core (~> 2.12.0)
131
+ rspec-expectations (~> 2.12.0)
132
+ rspec-mocks (~> 2.12.0)
133
+ simplecov (0.7.1)
134
+ multi_json (~> 1.0)
135
+ simplecov-html (~> 0.7.1)
136
+ simplecov-html (0.7.1)
137
+ slop (3.3.3)
138
+ sprockets (2.2.2)
139
+ hike (~> 1.2)
140
+ multi_json (~> 1.0)
141
+ rack (~> 1.0)
142
+ tilt (~> 1.1, != 1.3.0)
143
+ systemu (2.5.2)
144
+ thor (0.16.0)
145
+ tilt (1.3.3)
146
+ treetop (1.4.12)
147
+ polyglot
148
+ polyglot (>= 0.3.1)
149
+ tzinfo (0.3.35)
150
+ uuid (2.3.6)
151
+ macaddr (~> 1.0)
152
+
153
+ PLATFORMS
154
+ ruby
155
+
156
+ DEPENDENCIES
157
+ appraisal
158
+ crashlog!
159
+ delorean
160
+ guard-rspec
161
+ json_spec
162
+ rack-test
163
+ rails (= 3.2.9)
164
+ rake (= 0.9.2)
165
+ rspec
166
+ rspec-rails
167
+ simplecov
168
+ uuid
data/lib/crash_log.rb CHANGED
@@ -15,6 +15,8 @@ require_relative 'crash_log/reporter'
15
15
  require_relative 'crash_log/system_information'
16
16
  require_relative 'crash_log/rack'
17
17
 
18
+ require_relative "crash_log/sidekiq" if defined?(Sidekiq)
19
+
18
20
  module CrashLog
19
21
  extend Logging::ClassMethods
20
22
 
@@ -28,6 +28,7 @@ module CrashLog
28
28
  @context = {}
29
29
  @environment = {}
30
30
  @data = {}
31
+ @session = {}
31
32
  @backtrace_filters = config[:backtrace_filters] || []
32
33
 
33
34
  # Actually serialize the exception/event hash for transport
@@ -64,7 +65,7 @@ module CrashLog
64
65
  end
65
66
 
66
67
  def add_session_data(data)
67
- (@data[:session] ||= {}).merge!(data) if data.is_a?(Hash)
68
+ (@session ||= {}).merge!(data) if data.is_a?(Hash)
68
69
  end
69
70
 
70
71
  def add_environment_data(data)
@@ -2,18 +2,31 @@ module CrashLog
2
2
  module Rails
3
3
  module ControllerMethods
4
4
 
5
- def crash_log_context
6
- {
7
- :context => {
8
- :controller => params[:controller],
9
- :action => params[:action],
10
- :current_user => crash_log_current_user
11
- },
12
- :parameters => crash_log_filter_if_filtering(params.to_hash),
13
- :session_data => crash_log_filter_if_filtering(crash_log_session_data),
14
- :url => crash_log_request_url,
15
- :cgi_data => crash_log_filter_if_filtering(request.env),
16
- }
5
+ # def crash_log_context_old(env = nil)
6
+ # {
7
+ # :context => {
8
+ # :controller => params[:controller],
9
+ # :action => params[:action],
10
+ # :current_user => crash_log_current_user
11
+ # },
12
+ # :request => process_headers(request.env),
13
+ # :response => process_response,
14
+ # :parameters => crash_log_filter_if_filtering(params.to_hash),
15
+ # :session_data => crash_log_filter_if_filtering(crash_log_session_data),
16
+ # :url => crash_log_request_url,
17
+ # :cgi_data => crash_log_filter_if_filtering(request.env),
18
+ # }
19
+ # end
20
+
21
+ def crash_log_context(env)
22
+ payload = {}
23
+
24
+ payload[:request] = process_request(request.env)
25
+ payload[:response] = process_response
26
+ payload[:user] = crash_log_current_user
27
+ payload[:context] = process_context
28
+
29
+ payload
17
30
  end
18
31
 
19
32
  private
@@ -32,6 +45,69 @@ module CrashLog
32
45
  end
33
46
  end
34
47
 
48
+ def process_response
49
+ response = {}
50
+
51
+ if self.respond_to?(:response) && self.response.respond_to?(:headers)
52
+ response.merge!({:headers => self.response.headers})
53
+ end
54
+
55
+ response
56
+ end
57
+
58
+ def process_request(env)
59
+ headers, environment = {}, {}
60
+ data = nil
61
+ env.each_pair do |key, value|
62
+ next unless key.upcase == key # Non-upper case stuff isn't a header
63
+ if key.start_with?('HTTP_')
64
+ # Header
65
+ http_key = key[5..key.length-1].split('_').map{|s| s.capitalize}.join('-')
66
+ headers[http_key] = value.to_s
67
+ else
68
+ # Environment
69
+ environment[key] = value.to_s
70
+ end
71
+ end
72
+
73
+ require 'rack'
74
+ req = ::Rack::Request.new(env)
75
+ query_string = req.query_string
76
+ method = req.request_method
77
+ url = req.url.split('?').first
78
+ cookies = req.cookies
79
+
80
+ data = if req.form_data?
81
+ req.POST
82
+ elsif req.body
83
+ data = req.body.read
84
+ req.body.rewind
85
+ data
86
+ end
87
+
88
+ {
89
+ :url => url,
90
+ :query_string => query_string,
91
+ :method => method,
92
+ :headers => headers,
93
+ :cookies => cookies,
94
+ :parameters => crash_log_filter_if_filtering(params.to_hash),
95
+ :environment => environment,
96
+ :session => crash_log_filter_if_filtering(crash_log_session_data),
97
+ :data => data
98
+ }
99
+ end
100
+
101
+ def process_context
102
+ {
103
+ :controller => params[:controller],
104
+ :action => params[:action]
105
+ }
106
+
107
+ rescue NoMethodError
108
+ {}
109
+ end
110
+
35
111
  def crash_log_request_url
36
112
  url = "#{request.protocol}#{request.host}"
37
113
 
@@ -56,13 +132,17 @@ module CrashLog
56
132
  end
57
133
 
58
134
  def crash_log_current_user
59
- # Credit to Airbrake gem for this one.
135
+ user_hash = {}
136
+ user_attributes = CrashLog.configuration.user_attributes
60
137
  user = begin current_user rescue current_member end
61
- user.attributes.select do |k, v|
62
- CrashLog.configuration.
63
- user_attributes.map(&:to_sym).
64
- include?(k.to_sym) unless v.blank?
65
- end.symbolize_keys
138
+
139
+ user_attributes.map(&:to_sym).each do |attribute|
140
+ if user.respond_to?(attribute)
141
+ user_hash[attribute] = user.__send__(attribute)
142
+ end
143
+ end
144
+
145
+ user_hash
66
146
  rescue NoMethodError, NameError
67
147
  {}
68
148
  end