class BinlogReaderCommand::Head
Constants
- DEFAULT_HEAD_OPTIONS
Public Class Methods
new(argv = ARGV)
click to toggle source
Calls superclass method
BinlogReaderCommand::Formattable.new
# File lib/fluent/command/binlog_reader.rb, line 158 def initialize(argv = ARGV) super @options.merge!(default_options) parse_options! end
Public Instance Methods
call()
click to toggle source
# File lib/fluent/command/binlog_reader.rb, line 164 def call @formatter = lookup_formatter(@options[:format], @options[:config_params]) File.open(@path, 'r') do |io| i = 1 Fluent::MessagePackFactory.unpacker(io).each do |(time, record)| print @formatter.format(@path, time, record) # path is used for tag break if @options[:count] && i == @options[:count] i += 1 end end end
Private Instance Methods
default_options()
click to toggle source
# File lib/fluent/command/binlog_reader.rb, line 179 def default_options DEFAULT_HEAD_OPTIONS end
parse_options!()
click to toggle source
Calls superclass method
BinlogReaderCommand::Base#parse_options!
# File lib/fluent/command/binlog_reader.rb, line 183 def parse_options! @opt_parser.on('-n COUNT', 'Set the number of lines to display') do |v| @options[:count] = v.to_i usage "illegal line count -- #{@options[:count]}" if @options[:count] < 1 end super usage 'Path is required' if @argv.empty? @path = @argv.first usage "#{@path} is not found" unless File.exist?(@path) end