Sha256: 29961704a7a71064c5fe2db54acab5604c12dcaab2f66a21b1c43b62503c3f53
Contents?: true
Size: 765 Bytes
Versions: 12
Compression:
Stored size: 765 Bytes
Contents
require "benchmark" module MiniMagick ## # Responsible for logging commands to stdout (activated when # `MiniMagick.debug` is set to `true`). Implements a simplified Logger # interface. # # @private # class Logger attr_accessor :format def initialize(io) @io = io @format = "[%<duration>.2fs] %<command>s" end def debug(command, &action) benchmark(action) do |duration| output(duration: duration, command: command) if MiniMagick.debug end end def output(data) printf @io, "#{format}\n", data end def benchmark(action) return_value = nil duration = Benchmark.realtime { return_value = action.call } yield duration return_value end end end
Version data entries
12 entries across 12 versions & 1 rubygems