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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 45016049bfc7fea331fe1718c7a39c632c7aca38f3df4aa70ac97ca8c6e2b820
4
- data.tar.gz: 2f940d6a1d6a39ca65af8e3e25c9ce9a422fb093b2da65219fd79516f96d3651
2
+ SHA1:
3
+ metadata.gz: 721bf94bc8e941d9290d2f95cf9ef810b1972b0d
4
+ data.tar.gz: 1e7dac2b605c0d3f86c93732698cd9a0f1bb6171
5
5
  SHA512:
6
- metadata.gz: 799e7561dd05166a40d527b0d6e7c1c191fb1c3b5e40dd292261aeffc6c8daf2ba6603acc8e9610995050ee51ddfd70669ded4fa74492b8d59aa2e01b40b794a
7
- data.tar.gz: 989d22b2883cb81a1e3645ed15ffa49b29b34e7136737ea6dcd4a27f530da23b9461226166a25c61db0f6c9a5eb6afb06a16690d6e60662d35950e63c5b8b12c
6
+ metadata.gz: 1171c969cf10eb04f5d1aca1137dfa3395f65fa010cc948ad6a65a5801885cb1508d9cf103f774e853d4c05aadaaed14c58b10f7df7cf926e9d42efb1336dbce
7
+ data.tar.gz: 9297aa3f587abc16c395260817cc0e33150b8ab521c32ca1875c3291e61c0ada592c0f498f10b3e519dd07f2e6c7f558a1194b18c7e3e1810bd581e894c007f3
@@ -1,3 +1,3 @@
1
1
  module RollbarHelper
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'.freeze
3
3
  end
@@ -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
- def critical(obj, fingerprint: nil, **data)
15
- log(:critical, obj, :callee => caller, fingerprint: fingerprint, **data)
16
- end
17
-
18
- def debug(obj, fingerprint: nil, **data)
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
- def error(obj, fingerprint: nil, **data)
23
- log(:error, obj, :callee => caller, fingerprint: fingerprint, **data)
24
- end
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
- def info(obj, fingerprint: nil, **data)
27
- log(:info, obj, :callee => caller, fingerprint: fingerprint, **data)
27
+ get_notifier(fingerprint).public_send(level, message, exception, data)
28
+ end
28
29
  end
29
30
 
30
- def warn(obj, fingerprint: nil, **data)
31
- log(:warning, obj, :callee => caller, fingerprint: fingerprint, **data)
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
- def warning(obj, fingerprint: nil, **data)
35
- log(:warning, obj, :callee => caller, fingerprint: fingerprint, **data)
36
- end
36
+ private
37
37
 
38
- def log(level, obj, callee: caller, fingerprint: nil, **data)
39
- level = level.to_sym
40
- raise ArgumentError, 'Log level is not supported' unless LEVELS.include?(level)
41
- e = nil
38
+ def extract_arguments(args)
39
+ message = exception = nil
40
+ extra = {}
42
41
 
43
- if obj.is_a?(Exception)
44
- e = obj
45
- else
46
- e = StandardError.new(obj.to_s)
47
- e.set_backtrace(callee)
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
- unless fingerprint.nil?
51
- ::Rollbar.scope(:fingerprint => fingerprint).send(level, e, data)
52
- else
53
- ::Rollbar.send(level, e, data)
54
- end
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.0.0
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: 2021-10-28 00:00:00.000000000 Z
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
- rubygems_version: 3.2.3
124
- signing_key:
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: []