Class: BinlogReaderCommand::Head
Direct Known Subclasses
Cat
Constant Summary
collapse
- DEFAULT_HEAD_OPTIONS =
{
count: 5
}
Constants included
from Formattable
Formattable::DEFAULT_OPTIONS
Instance Method Summary
collapse
Constructor Details
#initialize(argv = ARGV) ⇒ Head
158
159
160
161
162
|
# File 'lib/fluent/command/binlog_reader.rb', line 158
def initialize(argv = ARGV)
super
@options.merge!(default_options)
parse_options!
end
|
Instance Method Details
#call ⇒ Object
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/fluent/command/binlog_reader.rb', line 164
def call
@formatter = lookup_formatter(@options[:format], @options[:config_params])
File.open(@path, 'rb') do |io|
i = 1
Fluent::MessagePackFactory.unpacker(io).each do |(time, record)|
print @formatter.format(@path, time, record)
break if @options[:count] && i == @options[:count]
i += 1
end
end
end
|