technologic 0.25.3 → 0.25.8

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: 2fac527e781d749fb20e815bfc288adc1e22a40297e80a75805e1632442886c0
4
- data.tar.gz: 9a4244bdafac62e23eb0019e1d85b1d892641191faf80c780cf70610b2a88790
3
+ metadata.gz: 867ea0c1c13f987e6ea9c148375f50803155ff34c6ead84b92e94af1138cdf00
4
+ data.tar.gz: 25b698e4db148102e8572603271ca1d356ec68db440be4a8f725aecedaab6b69
5
5
  SHA512:
6
- metadata.gz: 16d11b6464725b8a451c7633853c2c7e3d74e51ddf4b10504fc9071567101737e0b77d0441378be164a6ed297b055dbcdddda3757ceb899eda3a0dba74060dd8
7
- data.tar.gz: a958d41ac5d074e01560decd34c1f3f66fb4ededba5baa4c9b60ffec516e6ad3e63ffe066bdd02248cbd13dac07e2a1097c7ec28bbb931fa7655bf256829565d
6
+ metadata.gz: 58e5345aa69a1af3e8c52eb62a292c3de36438a1761c4e74d4629fd9ebdd029d782eb0c41b6603e07b3c14e5f325691fbd2114e5cdd0fd93fc5ea9cbbdd0a166
7
+ data.tar.gz: 28e937ff41ba8417fd452634c39b6136ec996c336ab168a9da111e90db07c340d2a4f0262e2aff2498275c498e0044f5ae43bc5dabff0ff0f3666e7c01ccae05
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,43 @@ 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
+ self.class.instrument(*args, **opts, &block)
60
+ end
61
+
62
+ module ClassMethods
63
+ # DEP-2021-01-14
64
+ # Remove this method
65
+ def instrument(*args, **opts, &block)
66
+ ActiveSupport::Deprecation.warn("Technologic.instrument is deprecated. Instead, use the corresponding severity-level convenience method (#info, #error etc)")
67
+
68
+ _tl_instrument(*args, **opts, &block)
57
69
  end
58
70
 
59
71
  def surveil(event, severity: :info, **data, &block)
60
72
  raise LocalJumpError unless block_given?
61
73
 
62
- instrument(severity, "#{event}_started", **data)
63
- instrument(severity, "#{event}_finished", &block)
74
+ raise ArgumentError, "Invalid severity: #{severity}" unless severity.to_sym.in?(SEVERITIES)
75
+
76
+ _tl_instrument(severity, "#{event}_started", **data)
77
+ _tl_instrument(severity, "#{event}_finished", &block)
64
78
  end
65
79
 
66
80
  SEVERITIES.each do |severity|
67
- define_method(severity) { |event, **data, &block| instrument(severity, event, **data, &block) }
81
+ define_method(severity) { |event, **data, &block| _tl_instrument(severity, event, **data, &block) }
68
82
  end
69
83
 
70
84
  EXCEPTION_SEVERITIES.each do |severity|
71
85
  define_method("#{severity}!") do |exception = StandardError, message = nil, **data, &block|
72
86
  if exception.is_a?(Exception)
73
- instrument(
87
+ _tl_instrument(
74
88
  severity,
75
89
  exception.class.name.demodulize,
76
90
  **{
@@ -83,11 +97,22 @@ module Technologic
83
97
 
84
98
  raise exception
85
99
  else
86
- instrument severity, exception.name.demodulize, message: message, **data, &block
100
+ _tl_instrument severity, exception.name.demodulize, message: message, **data, &block
87
101
  raise exception, message
88
102
  end
89
103
  end
90
104
  end
105
+
106
+ protected
107
+
108
+ def _tl_instrument(severity, event, **data, &block)
109
+ ActiveSupport::Notifications.instrument("#{event}.#{name}.#{severity}", data, &block).tap do
110
+ # If a block was defined, :instrument will return the value of the block.
111
+ # Otherwise, :instrument will return nil, since it didn't do anything.
112
+ # Returning true here allows us to do fun things like `info :subscription_created and return subscription`
113
+ return true unless block_given?
114
+ end
115
+ end
91
116
  end
92
117
  end
93
118
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Technologic
4
4
  # This constant is managed by spicerack
5
- VERSION = "0.25.3"
5
+ VERSION = "0.25.8"
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.3
4
+ version: 0.25.8
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-12-23 00:00:00.000000000 Z
11
+ date: 2021-04-12 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.3
33
+ version: 0.25.8
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.3
40
+ version: 0.25.8
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.3
90
+ documentation_uri: https://www.rubydoc.info/gems/technologic/0.25.8
91
91
  post_install_message:
92
92
  rdoc_options: []
93
93
  require_paths: