Sha256: 0fab63524d555a9ae3b5eae7ae520ede546eea9c3771baa9f7c0992b2f57758e

Contents?: true

Size: 797 Bytes

Versions: 31

Compression:

Stored size: 797 Bytes

Contents

# Use the Ruby/Rails logger
require 'active_support/core_ext/logger'
require "securerandom"

module Middleman

  # The Middleman Logger
  class Logger < ::Logger

    # Force output to STDOUT
    def initialize(log_level=1, is_instrumenting=false, target=STDOUT)
      super(STDOUT)

      self.level = log_level
      @instrumenting = is_instrumenting

      if @instrumenting != false
        ::ActiveSupport::Notifications.subscribe(/\.middleman$/, self)
      end
    end

    def call(message, *args)
      return if @instrumenting.is_a?(String) && @instrumenting != "instrument" && !message.include?(@instrumenting)

      evt = ActiveSupport::Notifications::Event.new(message, *args)
      self.info "== Instrument (#{evt.name.sub(/.middleman$/, '')}): #{evt.duration}ms"
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
middleman-core-x86-mingw32-3.0.12 lib/middleman-core/logger.rb
middleman-core-3.0.12 lib/middleman-core/logger.rb
middleman-core-x86-mingw32-3.0.12.pre.1 lib/middleman-core/logger.rb
middleman-core-3.0.12.pre.1 lib/middleman-core/logger.rb
middleman-core-x86-mingw32-3.0.11 lib/middleman-core/logger.rb
middleman-core-3.0.11 lib/middleman-core/logger.rb
middleman-core-x86-mingw32-3.0.10 lib/middleman-core/logger.rb
middleman-core-x86-mingw32-3.0.10.pre.1 lib/middleman-core/logger.rb
middleman-core-3.0.10.pre.1 lib/middleman-core/logger.rb
middleman-core-x86-mingw32-3.0.9 lib/middleman-core/logger.rb
middleman-core-3.0.9 lib/middleman-core/logger.rb
middleman-core-x86-mingw32-3.0.8 lib/middleman-core/logger.rb
middleman-core-3.0.8 lib/middleman-core/logger.rb
middleman-core-x86-mingw32-3.0.8.pre.2 lib/middleman-core/logger.rb
middleman-core-3.0.8.pre.2 lib/middleman-core/logger.rb
middleman-core-x86-mingw32-3.0.8.pre.1 lib/middleman-core/logger.rb
middleman-core-3.0.8.pre.1 lib/middleman-core/logger.rb
middleman-core-x86-mingw32-3.0.7 lib/middleman-core/logger.rb
middleman-core-3.0.7 lib/middleman-core/logger.rb
middleman-core-x86-mingw32-3.0.6 lib/middleman-core/logger.rb