Sha256: bc14d7e3f66e5ad8ea906ef6571650e2ca008ca06d8f20e5667571b1b980522e

Contents?: true

Size: 785 Bytes

Versions: 3

Compression:

Stored size: 785 Bytes

Contents

require "logstash/namespace"
require "logstash/event"
require "logstash/logging"
require "uri"

class LogStash::Inputs::Base
  attr_accessor :logger
  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 = []
  end

  def register
    raise "#{self.class}#register must be overidden"
  end

  def tag(newtag)
    @tags << newtag
  end

  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
end # class LogStash::Inputs::Base

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
logstash-lite-0.2.20101222161646 lib/logstash/inputs/base.rb
logstash-lite-0.2.20101208111718 lib/logstash/inputs/base.rb
logstash-lite-0.2.20101207114354 lib/logstash/inputs/base.rb