rollbar_helper 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/rollbar_helper/version.rb +1 -1
- data/lib/rollbar_helper.rb +44 -34
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 721bf94bc8e941d9290d2f95cf9ef810b1972b0d
|
4
|
+
data.tar.gz: 1e7dac2b605c0d3f86c93732698cd9a0f1bb6171
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1171c969cf10eb04f5d1aca1137dfa3395f65fa010cc948ad6a65a5801885cb1508d9cf103f774e853d4c05aadaaed14c58b10f7df7cf926e9d42efb1336dbce
|
7
|
+
data.tar.gz: 9297aa3f587abc16c395260817cc0e33150b8ab521c32ca1875c3291e61c0ada592c0f498f10b3e519dd07f2e6c7f558a1194b18c7e3e1810bd581e894c007f3
|
data/lib/rollbar_helper.rb
CHANGED
@@ -3,55 +3,65 @@ require 'rollbar_helper/version'
|
|
3
3
|
|
4
4
|
module RollbarHelper
|
5
5
|
LEVELS = [
|
6
|
-
:critical,
|
7
6
|
:debug,
|
8
|
-
:error,
|
9
7
|
:info,
|
10
8
|
:warning,
|
11
|
-
|
9
|
+
:error,
|
10
|
+
:critical,
|
11
|
+
].freeze
|
12
12
|
|
13
13
|
class << self
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
log(:debug, obj, :callee => caller, fingerprint: fingerprint, **data)
|
20
|
-
end
|
14
|
+
LEVELS.each do |level|
|
15
|
+
define_method(level) do |*args|
|
16
|
+
message, exception, extra = extract_arguments(args)
|
17
|
+
extra = { callee: caller }.merge(extra)
|
18
|
+
data, exception, callee, fingerprint = split_extra_arg(extra, exception)
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
if !message.nil? && exception.nil?
|
21
|
+
exception = StandardError.new(message).tap do |e|
|
22
|
+
e.set_backtrace(callee)
|
23
|
+
end
|
24
|
+
message = nil
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
27
|
+
get_notifier(fingerprint).public_send(level, message, exception, data)
|
28
|
+
end
|
28
29
|
end
|
29
30
|
|
30
|
-
def
|
31
|
-
|
31
|
+
def log(level, *args)
|
32
|
+
raise ArgumentError, 'Log level is not supported' unless LEVELS.include?(level.to_sym)
|
33
|
+
send(level, { callee: caller }, *args)
|
32
34
|
end
|
33
35
|
|
34
|
-
|
35
|
-
log(:warning, obj, :callee => caller, fingerprint: fingerprint, **data)
|
36
|
-
end
|
36
|
+
private
|
37
37
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
e = nil
|
38
|
+
def extract_arguments(args)
|
39
|
+
message = exception = nil
|
40
|
+
extra = {}
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
args.each do |arg|
|
43
|
+
if arg.is_a?(String)
|
44
|
+
message = arg
|
45
|
+
elsif arg.is_a?(Exception)
|
46
|
+
exception = arg
|
47
|
+
elsif arg.is_a?(Hash)
|
48
|
+
extra = extra.merge(arg)
|
49
|
+
end
|
48
50
|
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
[message, exception, extra]
|
53
|
+
end
|
54
|
+
|
55
|
+
def split_extra_arg(extra, exception)
|
56
|
+
exception ||= extra.delete(:e) # Core legacy support
|
57
|
+
callee = extra.delete(:callee)
|
58
|
+
fingerprint = extra.delete(:fingerprint)
|
59
|
+
[extra, exception, callee, fingerprint]
|
60
|
+
end
|
61
|
+
|
62
|
+
def get_notifier(fingerprint)
|
63
|
+
return Rollbar if fingerprint.nil?
|
64
|
+
Rollbar.scope(fingerprint: fingerprint)
|
55
65
|
end
|
56
66
|
end
|
57
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rollbar_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Santiago Herrera
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.2'
|
83
|
-
description:
|
83
|
+
description:
|
84
84
|
email:
|
85
85
|
- santi.4096@gmail.com
|
86
86
|
executables: []
|
@@ -105,7 +105,7 @@ licenses:
|
|
105
105
|
- MIT
|
106
106
|
metadata:
|
107
107
|
allowed_push_host: https://rubygems.org
|
108
|
-
post_install_message:
|
108
|
+
post_install_message:
|
109
109
|
rdoc_options: []
|
110
110
|
require_paths:
|
111
111
|
- lib
|
@@ -120,8 +120,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
|
-
|
124
|
-
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.5.2.3
|
125
|
+
signing_key:
|
125
126
|
specification_version: 4
|
126
127
|
summary: Displays a stacktrace in rollbar
|
127
128
|
test_files: []
|