technologic 0.25.1 → 0.25.6

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
2
  SHA256:
3
- metadata.gz: 235ef4113251dd4e7af4aa97d8048ffe017e27b70e6a0052bf9f9371bfd99a0a
4
- data.tar.gz: 39c501d0a9ddbc770958c5dc3ea1caeaad60e70bf85a5c9f92c3f9da070a5978
3
+ metadata.gz: 8862051627d0660bf5af09d000c98fde7202bfdafa589abb169caaae0deade1a
4
+ data.tar.gz: e0d130ac7d14db924d3ba7e5de667677f5b76c84352597335c2fafa3c2351895
5
5
  SHA512:
6
- metadata.gz: 4d41e9dddbf5c37c730ec4e4ff3120e7bc78e25524ab6f89f92402a4d168ff932eaf5b7b421d8e67cd1348febb03da9ec8c4e5b7946077f3e01ab37567be443d
7
- data.tar.gz: 773014349cfbfc35fd0cc00823584956aefae5c1597f58f36fb1c2065ea354b612fdd2b889277f14c0b342d50c81ffe5847983ec3d5ebc8034733b21788db9cf
6
+ metadata.gz: 2624b7de7926d4d9f094f817d6c09043522305c205c09b99b5df8b0ab51803d2a6032e8d49e012ebf5672bdd4de7f437e21a16df37946e13950afaf050ebcaae
7
+ data.tar.gz: 1ca96df750bfccf41267565aac1f084ff6b06d15c6e5f2615192d4fc7a19739ced8cd060d39e891dee767a7acabc782de4ce5700d4fa8e83e39ed8920a476fe8
data/lib/technologic.rb CHANGED
@@ -29,9 +29,11 @@ module Technologic
29
29
  SEVERITIES = %i[debug info warn error fatal].freeze
30
30
  EXCEPTION_SEVERITIES = %i[error fatal].freeze
31
31
 
32
+ ACTIVEJOB_WORKAROUND_FIRST_VERSION = Gem::Version.new("6.1.0")
33
+
32
34
  included do
33
- delegate :instrument, :surveil, to: :class
34
- protected :instrument, :surveil
35
+ delegate :_tl_instrument, :surveil, to: :class
36
+ protected :_tl_instrument, :surveil
35
37
 
36
38
  SEVERITIES.each do |severity|
37
39
  delegate severity, to: :class
@@ -46,31 +48,45 @@ module Technologic
46
48
  end
47
49
  end
48
50
 
49
- class_methods do
50
- def instrument(severity, event, **data, &block)
51
- ActiveSupport::Notifications.instrument("#{event}.#{name}.#{severity}", data, &block).tap do
52
- # If a block was defined, :instrument will return the value of the block.
53
- # Otherwise, :instrument will return nil, since it didn't do anything.
54
- # Returning true here allows us to do fun things like `info :subscription_created and return subscription`
55
- return true unless block_given?
56
- end
51
+ protected
52
+
53
+ # DEP-2021-01-14
54
+ # Remove this method
55
+ def instrument(*args, **opts, &block)
56
+ # Targeted workaround for ActiveJob#instrument in Rails 6.1+
57
+ return super if defined?(ActiveJob) && self.class <= ActiveJob::Base && ActiveJob.version >= ACTIVEJOB_WORKAROUND_FIRST_VERSION
58
+
59
+ ActiveSupport::Deprecation.warn("Technologic#instrument is deprecated. Instead, use the corresponding severity-level convenience method (#info, #error etc)")
60
+
61
+ _tl_instrument(*args, **opts, &block)
62
+ end
63
+
64
+ module ClassMethods
65
+ # DEP-2021-01-14
66
+ # Remove this method
67
+ def instrument(*args, **opts, &block)
68
+ ActiveSupport::Deprecation.warn("Technologic.instrument is deprecated. Instead, use the corresponding severity-level convenience method (#info, #error etc)")
69
+
70
+ _tl_instrument(*args, **opts, &block)
57
71
  end
58
72
 
59
73
  def surveil(event, severity: :info, **data, &block)
60
74
  raise LocalJumpError unless block_given?
61
75
 
62
- instrument(severity, "#{event}_started", **data)
63
- instrument(severity, "#{event}_finished", &block)
76
+ raise ArgumentError, "Invalid severity: #{severity}" unless severity.to_sym.in?(SEVERITIES)
77
+
78
+ _tl_instrument(severity, "#{event}_started", **data)
79
+ _tl_instrument(severity, "#{event}_finished", &block)
64
80
  end
65
81
 
66
82
  SEVERITIES.each do |severity|
67
- define_method(severity) { |event, **data, &block| instrument(severity, event, **data, &block) }
83
+ define_method(severity) { |event, **data, &block| _tl_instrument(severity, event, **data, &block) }
68
84
  end
69
85
 
70
86
  EXCEPTION_SEVERITIES.each do |severity|
71
87
  define_method("#{severity}!") do |exception = StandardError, message = nil, **data, &block|
72
88
  if exception.is_a?(Exception)
73
- instrument(
89
+ _tl_instrument(
74
90
  severity,
75
91
  exception.class.name.demodulize,
76
92
  **{
@@ -83,11 +99,22 @@ module Technologic
83
99
 
84
100
  raise exception
85
101
  else
86
- instrument severity, exception.name.demodulize, message: message, **data, &block
102
+ _tl_instrument severity, exception.name.demodulize, message: message, **data, &block
87
103
  raise exception, message
88
104
  end
89
105
  end
90
106
  end
107
+
108
+ protected
109
+
110
+ def _tl_instrument(severity, event, **data, &block)
111
+ ActiveSupport::Notifications.instrument("#{event}.#{name}.#{severity}", data, &block).tap do
112
+ # If a block was defined, :instrument will return the value of the block.
113
+ # Otherwise, :instrument will return nil, since it didn't do anything.
114
+ # Returning true here allows us to do fun things like `info :subscription_created and return subscription`
115
+ return true unless block_given?
116
+ end
117
+ end
91
118
  end
92
119
  end
93
120
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Technologic
4
4
  # This constant is managed by spicerack
5
- VERSION = "0.25.1"
5
+ VERSION = "0.25.6"
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: technologic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.1
4
+ version: 0.25.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Garside
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-13 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.25.1
33
+ version: 0.25.6
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.25.1
40
+ version: 0.25.6
41
41
  description: A clean and terse way to produce standardized, highly actionable, and
42
42
  data-rich logs
43
43
  email:
@@ -87,7 +87,7 @@ metadata:
87
87
  homepage_uri: https://github.com/Freshly/spicerack/tree/master/technologic
88
88
  source_code_uri: https://github.com/Freshly/spicerack/tree/master/technologic
89
89
  changelog_uri: https://github.com/Freshly/spicerack/blob/master/technologic/CHANGELOG.md
90
- documentation_uri: https://www.rubydoc.info/gems/technologic/0.25.1
90
+ documentation_uri: https://www.rubydoc.info/gems/technologic/0.25.6
91
91
  post_install_message:
92
92
  rdoc_options: []
93
93
  require_paths: