Class: Middleman::Logger
- Inherits:
-
ActiveSupport::BufferedLogger
- Object
- ActiveSupport::BufferedLogger
- Middleman::Logger
- Defined in:
- lib/middleman-core/logger.rb
Overview
The Middleman Logger
Instance Method Summary collapse
- #add(*args) ⇒ Object
- #call(message, *args) ⇒ Object
-
#initialize(log_level = 1, is_instrumenting = false, target = $stdout) ⇒ Logger
constructor
A new instance of Logger.
Constructor Details
#initialize(log_level = 1, is_instrumenting = false, target = $stdout) ⇒ Logger
Returns a new instance of Logger.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/middleman-core/logger.rb', line 10 def initialize(log_level=1, is_instrumenting=false, target=$stdout) super(target) self.level = log_level @instrumenting = is_instrumenting if @instrumenting != false ::ActiveSupport::Notifications.subscribe(/\.middleman$/, self) end @mutex = Mutex.new end |
Instance Method Details
#add(*args) ⇒ Object
23 24 25 26 27 |
# File 'lib/middleman-core/logger.rb', line 23 def add(*args) @mutex.synchronize do super end end |
#call(message, *args) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/middleman-core/logger.rb', line 29 def call(, *args) return if @instrumenting.is_a?(String) && @instrumenting != "instrument" && !.include?(@instrumenting) evt = ActiveSupport::Notifications::Event.new(, *args) self.info "== Instrument (#{evt.name.sub(/.middleman$/, '')}): #{evt.duration}ms" end |