Module: Technologic::ClassMethods
- Defined in:
- lib/technologic.rb
Instance Method Summary collapse
- #_tl_instrument(severity, event, **data, &block) ⇒ Object protected
-
#instrument(*args, **opts, &block) ⇒ Object
DEP-2021-01-14 Remove this method.
- #surveil(event, severity: :info, **data, &block) ⇒ Object
Instance Method Details
#_tl_instrument(severity, event, **data, &block) ⇒ Object (protected)
110 111 112 113 114 115 116 117 |
# File 'lib/technologic.rb', line 110 def _tl_instrument(severity, event, **data, &block) ActiveSupport::Notifications.instrument("#{event}.#{name}.#{severity}", data, &block).tap do # If a block was defined, :instrument will return the value of the block. # Otherwise, :instrument will return nil, since it didn't do anything. # Returning true here allows us to do fun things like `info :subscription_created and return subscription` return true unless block_given? end end |
#instrument(*args, **opts, &block) ⇒ Object
DEP-2021-01-14 Remove this method
67 68 69 70 71 |
# File 'lib/technologic.rb', line 67 def instrument(*args, **opts, &block) ActiveSupport::Deprecation.warn("Technologic.instrument is deprecated. Instead, use the corresponding severity-level convenience method (#info, #error etc)") _tl_instrument(*args, **opts, &block) end |
#surveil(event, severity: :info, **data, &block) ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/technologic.rb', line 73 def surveil(event, severity: :info, **data, &block) raise LocalJumpError unless block_given? raise ArgumentError, "Invalid severity: #{severity}" unless severity.to_sym.in?(SEVERITIES) __send__(severity, "#{event}_started", **data) __send__(severity, "#{event}_finished", &block) end |