class LogStash::Inputs::Base

Attributes

logger[RW]

Public Class Methods

new(url, type, config={}, &block) click to toggle source
# File lib/logstash/inputs/base.rb, line 10
def initialize(url, type, config={}, &block)
  @logger = LogStash::Logger.new(STDERR)
  @url = url
  @url = URI.parse(url) if url.is_a? String
  @config = config
  @callback = block
  @type = type
  @tags = []

  @urlopts = {}
  if @url.query
    @urlopts = CGI.parse(@url.query)
    @urlopts.each do |k, v|
      @urlopts[k] = v.last if v.is_a?(Array)
    end
  end
end

Public Instance Methods

receive(event) click to toggle source
# File lib/logstash/inputs/base.rb, line 39
def receive(event)
  @logger.debug(["Got event", { :url => @url, :event => event }])
  # Only override the type if it doesn't have one
  event.type = @type if !event.type 
  event.tags |= @tags # set union
  @callback.call(event)
end
register() click to toggle source
# File lib/logstash/inputs/base.rb, line 29
def register
  raise "#{self.class}#register must be overidden"
end
tag(newtag) click to toggle source
# File lib/logstash/inputs/base.rb, line 34
def tag(newtag)
  @tags << newtag
end