class Sawmill::EntryProcessor::InterpretStats

This processor interprets a stats log.

Public Class Methods

new(opts_={}, &block_) click to toggle source

Create a stats log interpreter.

# File lib/sawmill/entry_processor/interpret_stats.rb, line 49
def initialize(opts_={}, &block_)
  @handler = opts_[:handler] || block_ || method(:handle_data)
end

Public Instance Methods

finish() click to toggle source
# File lib/sawmill/entry_processor/interpret_stats.rb, line 69
def finish
  @handler.call(nil)
end
handle_data(data_) click to toggle source
# File lib/sawmill/entry_processor/interpret_stats.rb, line 64
def handle_data(data_)
  true
end
message(entry_) click to toggle source
# File lib/sawmill/entry_processor/interpret_stats.rb, line 54
def message(entry_)
  data_ = ::JSON.parse(entry_.message) rescue nil
  if data_.is_a?(::Hash)
    @handler.call(data_)
  else
    nil
  end
end