Sha256: 521ab74b9a9dff85c934621c93f588dbaef019e6b5dbd31d7a2bfc9c36ab4a24
Contents?: true
Size: 984 Bytes
Versions: 16
Compression:
Stored size: 984 Bytes
Contents
# encoding: utf-8 module Moped module Instrumentable # Provides logging instrumentation for compatibility with active support # notifications. # # @since 2.0.0 module Log extend self # Instrument the log payload. # # @example Instrument the log payload. # Log.instrument("moped.ops", {}) # # @param [ String ] name The name of the logging type. # @param [ Hash ] payload The log payload. # # @return [ Object ] The result of the yield. # # @since 2.0.0 def instrument(name, payload = {}) started = Time.new begin yield if block_given? rescue Exception => e payload[:exception] = [ e.class.name, e.message ] raise e ensure runtime = ("%.4fms" % (1000 * (Time.now.to_f - started.to_f))) Moped::Loggable.log_operations(payload[:prefix], payload[:ops], runtime) end end end end end
Version data entries
16 entries across 16 versions & 2 rubygems