Class: Middleman::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/middleman-core/logger.rb

Overview

The Middleman Logger

Instance Method Summary collapse

Constructor Details

#initialize(log_level = 1, is_instrumenting = false, target = STDOUT) ⇒ Logger

Force output to STDOUT



10
11
12
13
14
15
16
17
18
19
# File 'lib/middleman-core/logger.rb', line 10

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

Instance Method Details

#call(message, *args) ⇒ Object



21
22
23
24
25
26
# File 'lib/middleman-core/logger.rb', line 21

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