ratchetio 0.3.0 → 0.3.1
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/README.md +34 -16
- data/lib/generators/ratchetio/templates/initializer.rb +6 -0
- data/lib/ratchetio/configuration.rb +6 -0
- data/lib/ratchetio/version.rb +1 -1
- data/lib/ratchetio.rb +10 -5
- metadata +2 -2
data/README.md
CHANGED
@@ -32,30 +32,36 @@ This will raise an exception within a test request; if it works, you'll see a st
|
|
32
32
|
|
33
33
|
To report a caught exception to Ratchet, simply call `Ratchetio.report_exception`:
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
```ruby
|
36
|
+
begin
|
37
|
+
foo = bar
|
38
|
+
rescue Exception => e
|
39
|
+
Ratchetio.report_exception(e)
|
40
|
+
end
|
41
|
+
```
|
40
42
|
|
41
43
|
If you're reporting an exception in the context of a request and are in a controller, you can pass along the same request and person context as the global exception handler, like so:
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
```ruby
|
46
|
+
begin
|
47
|
+
foo = bar
|
48
|
+
rescue Exception => e
|
49
|
+
Ratchetio.report_exception(e, ratchetio_request_data, ratchetio_person_data)
|
50
|
+
end
|
51
|
+
```
|
48
52
|
|
49
53
|
You can also log individual messages:
|
50
54
|
|
51
|
-
|
52
|
-
|
55
|
+
```ruby
|
56
|
+
# logs at the 'warning' level. all levels: debug, info, warning, error, critical
|
57
|
+
Ratchetio.report_message("Unexpected input", "warning")
|
53
58
|
|
54
|
-
|
55
|
-
|
59
|
+
# default level is "info"
|
60
|
+
Ratchetio.report_message("Login successful")
|
56
61
|
|
57
|
-
|
58
|
-
|
62
|
+
# can also include additional data as a hash in the final param
|
63
|
+
Ratchetio.report_message("Login successful", "info", :user => @user)
|
64
|
+
```
|
59
65
|
|
60
66
|
|
61
67
|
## Person tracking
|
@@ -69,6 +75,18 @@ alias_method :my_user_method, :current_user
|
|
69
75
|
helper_method :my_user_method
|
70
76
|
```
|
71
77
|
|
78
|
+
|
79
|
+
## Exception level filters
|
80
|
+
|
81
|
+
By default, all exceptions reported through `Ratchetio.report_exception()` are reporeted at the "error" level, except for the following, which are reported at "warning" level:
|
82
|
+
|
83
|
+
- ActiveRecord::RecordNotFound
|
84
|
+
- AbstractController::ActionNotFound
|
85
|
+
- ActionController::RoutingError
|
86
|
+
|
87
|
+
If you'd like to customize this list, see the example code in `config/initializers/ratchetio.rb`. Supported levels: "critical", "error", "warning", "info", "debug".
|
88
|
+
|
89
|
+
|
72
90
|
## Help / Support
|
73
91
|
|
74
92
|
If you run into any issues, please email me at brian@ratchet.io
|
@@ -1,4 +1,10 @@
|
|
1
1
|
require 'ratchetio/rails'
|
2
2
|
Ratchetio.configure do |config|
|
3
3
|
config.access_token = <%= access_token_expr %>
|
4
|
+
|
5
|
+
# Add exception class names to the exception_level_filters hash to
|
6
|
+
# change the level that exception is reported at. Note that if an exception
|
7
|
+
# has already been reported and logged the level will need to be changed
|
8
|
+
# via the ratchet.io interface.
|
9
|
+
# config.exception_level_filters.merge!('MyCriticalException' => 'critical')
|
4
10
|
end
|
@@ -7,6 +7,7 @@ module Ratchetio
|
|
7
7
|
attr_accessor :branch
|
8
8
|
attr_accessor :framework
|
9
9
|
attr_accessor :endpoint
|
10
|
+
attr_accessor :exception_level_filters
|
10
11
|
|
11
12
|
attr_accessor :logger
|
12
13
|
|
@@ -15,6 +16,11 @@ module Ratchetio
|
|
15
16
|
def initialize
|
16
17
|
@endpoint = DEFAULT_ENDPOINT
|
17
18
|
@framework = 'Plain'
|
19
|
+
@exception_level_filters = {
|
20
|
+
'ActiveRecord::RecordNotFound' => 'warning',
|
21
|
+
'AbstractController::ActionNotFound' => 'warning',
|
22
|
+
'ActionController::RoutingError' => 'warning'
|
23
|
+
}
|
18
24
|
end
|
19
25
|
|
20
26
|
# allow params to be read like a hash
|
data/lib/ratchetio/version.rb
CHANGED
data/lib/ratchetio.rb
CHANGED
@@ -31,8 +31,8 @@ module Ratchetio
|
|
31
31
|
|
32
32
|
payload = build_payload(data)
|
33
33
|
send_payload(payload)
|
34
|
-
rescue
|
35
|
-
logger.error "[Ratchet.io] Error reporting exception to Ratchet.io"
|
34
|
+
rescue Exception => e
|
35
|
+
logger.error "[Ratchet.io] Error reporting exception to Ratchet.io: #{e}"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -50,8 +50,8 @@ module Ratchetio
|
|
50
50
|
|
51
51
|
payload = build_payload(data)
|
52
52
|
send_payload(payload)
|
53
|
-
rescue
|
54
|
-
logger.error "[Ratchet.io] Error reporting message to Ratchet.io"
|
53
|
+
rescue Exception => e
|
54
|
+
logger.error "[Ratchet.io] Error reporting message to Ratchet.io: #{e}"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -69,7 +69,12 @@ module Ratchetio
|
|
69
69
|
}
|
70
70
|
# reverse so that the order is as ratchet expects
|
71
71
|
frames.reverse!
|
72
|
-
|
72
|
+
|
73
|
+
filtered_level = configuration.exception_level_filters[exception.class.name]
|
74
|
+
if filtered_level
|
75
|
+
data[:level] = filtered_level
|
76
|
+
end
|
77
|
+
|
73
78
|
data[:body] = {
|
74
79
|
:trace => {
|
75
80
|
:frames => frames,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ratchetio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Rails plugin to catch and send exceptions to Ratchet.io
|
15
15
|
email:
|