Sha256: dc3a432e0f94f250da5db581215f26e21cca634eaa0595b7104a93d94aad3bec

Contents?: true

Size: 1.04 KB

Versions: 99

Compression:

Stored size: 1.04 KB

Contents

# Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.io/terms.html

require 'sqreen/performance_notifications'

module Sqreen
  module PerformanceNotifications
    # Log performances on the console
    class Log
      @subid = nil
      @facility = nil
      class << self
        def log(event, start, finish, meta)
          (@facility || Sqreen.log).debug do
            meta_str = nil
            meta_str = ": #{meta.inspect}" unless meta.empty?
            format('%s took %.2fms%s', event, (finish - start) * 1000, meta_str)
          end
        end

        def enable(facility = nil)
          return unless @subid.nil?
          @facility = facility
          @subid = Sqreen::PerformanceNotifications.subscribe(nil,
                                                              &method(:log))
        end

        def disable
          return if @subid.nil?
          Sqreen::PerformanceNotifications.unsubscribe(@subid)
          @subid = nil
        end
      end
    end
  end
end

Version data entries

99 entries across 99 versions & 2 rubygems

Version Path
sqreen-1.11.0-java lib/sqreen/performance_notifications/log.rb
sqreen-alt-1.11.0 lib/sqreen/performance_notifications/log.rb
sqreen-1.11.0 lib/sqreen/performance_notifications/log.rb
sqreen-1.10.5-java lib/sqreen/performance_notifications/log.rb
sqreen-alt-1.10.5 lib/sqreen/performance_notifications/log.rb
sqreen-1.10.5 lib/sqreen/performance_notifications/log.rb
sqreen-1.10.4-java lib/sqreen/performance_notifications/log.rb
sqreen-alt-1.10.4 lib/sqreen/performance_notifications/log.rb
sqreen-1.10.4 lib/sqreen/performance_notifications/log.rb
sqreen-1.10.3-java lib/sqreen/performance_notifications/log.rb
sqreen-alt-1.10.3 lib/sqreen/performance_notifications/log.rb
sqreen-1.10.3 lib/sqreen/performance_notifications/log.rb
sqreen-1.10.2-java lib/sqreen/performance_notifications/log.rb
sqreen-alt-1.10.2 lib/sqreen/performance_notifications/log.rb
sqreen-1.10.2 lib/sqreen/performance_notifications/log.rb
sqreen-1.10.1-java lib/sqreen/performance_notifications/log.rb
sqreen-alt-1.10.1 lib/sqreen/performance_notifications/log.rb
sqreen-1.10.1 lib/sqreen/performance_notifications/log.rb
sqreen-1.10.0-java lib/sqreen/performance_notifications/log.rb
sqreen-alt-1.10.0 lib/sqreen/performance_notifications/log.rb