Class: MiniMagick::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/mini_magick/logger.rb

Overview

Responsible for logging commands to stdout (activated when ‘MiniMagick.debug` is set to `true`). Implements a simplified Logger interface.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ Logger

Returns a new instance of Logger.



15
16
17
18
# File 'lib/mini_magick/logger.rb', line 15

def initialize(io)
  @io     = io
  @format = "[%<duration>.2fs] %<command>s"
end

Instance Attribute Details

#formatObject

Returns the value of attribute format.



13
14
15
# File 'lib/mini_magick/logger.rb', line 13

def format
  @format
end

Instance Method Details

#debug(command, &action) ⇒ Object



20
21
22
23
24
# File 'lib/mini_magick/logger.rb', line 20

def debug(command, &action)
  benchmark(action) do |duration|
    output(duration: duration, command: command) if MiniMagick.debug
  end
end