Class: BinlogReaderCommand::Head
- Includes:
- Formattable
- Defined in:
- lib/fluent/command/binlog_reader.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_HEAD_OPTIONS =
{ count: 5 }
Constants included from Formattable
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(argv = ARGV) ⇒ Head
constructor
A new instance of Head.
Constructor Details
#initialize(argv = ARGV) ⇒ Head
Returns a new instance of Head.
168 169 170 171 172 |
# File 'lib/fluent/command/binlog_reader.rb', line 168 def initialize(argv = ARGV) super @options.merge!() end |
Instance Method Details
#call ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/fluent/command/binlog_reader.rb', line 174 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) # path is used for tag break if @options[:count] && i == @options[:count] i += 1 end end end |