class MysqlBinlog::DebuggingReader
Wrap another Reader class, passing through all method calls, but optionally printing the contents of data read, and the method calls themselves. This is very useful for debugging the library itself, or if exceptions are getting thrown when reading a possibly unsupported log.
Public Class Methods
new(wrapped, options={})
click to toggle source
# File lib/mysql_binlog/reader/debugging_reader.rb, line 17 def initialize(wrapped, options={}) @wrapped = wrapped @options = options end
Public Instance Methods
method_missing(method, *args)
click to toggle source
Pass through all method calls to the reader class we're delegating to. If various options are enabled, print debugging information.
# File lib/mysql_binlog/reader/debugging_reader.rb, line 24 def method_missing(method, *args) if @options[:calls] puts "#{@wrapped.class}.#{method}" end return_value = @wrapped.send(method, *args) # Print the returned data from :read in a nice hex dump format. if method == :read and @options[:data] puts "Read #{args[0]} bytes #{caller.first.split(":")[2]}:" puts hexdump(return_value) end return_value end