diff --git a/lib/logstash/inputs/base.rb b/lib/logstash/inputs/base.rb index cf97e9daf..4688fd549 100644 --- a/lib/logstash/inputs/base.rb +++ b/lib/logstash/inputs/base.rb @@ -2,7 +2,6 @@ require "logstash/namespace" require "logstash/event" require "logstash/logging" require "logstash/config/mixin" -require "uri" class LogStash::Inputs::Base include LogStash::Config::Mixin @@ -11,7 +10,7 @@ class LogStash::Inputs::Base config_name "input" config :type => :string - config :tag => (lambda do |value| + config :tags => (lambda do |value| re = /^[A-Za-z0-9_]+$/ value.each do |v| if v !~ re @@ -26,6 +25,8 @@ class LogStash::Inputs::Base def initialize(params) @logger = LogStash::Logger.new(STDERR) config_init(params) + + @tags ||= [] end # def initialize public @@ -37,13 +38,4 @@ class LogStash::Inputs::Base def tag(newtag) @tags << newtag end # def tag - - public - 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 # def receive end # class LogStash::Inputs::Base diff --git a/lib/logstash/inputs/internal.rb b/lib/logstash/inputs/internal.rb deleted file mode 100644 index a109ac558..000000000 --- a/lib/logstash/inputs/internal.rb +++ /dev/null @@ -1,42 +0,0 @@ -require "eventmachine-tail" -require "logstash/inputs/base" -require "logstash/namespace" -require "socket" # for Socket.gethostname - -class LogStash::Inputs::Internal < LogStash::Inputs::Base - attr_reader :channel - - config_name "internal" - - public - def initialize(params) - super - raise "issue/17: needs refactor to support configfile" - - # Default host to the machine's hostname if it's not set - @url.host ||= Socket.gethostname - @channel = EventMachine::Channel.new - end - - public - def register - @logger.info("Registering input #{@url}") - @channel.subscribe do |event| - receive(event) - end - end # def register - - public - def receive(event) - if !event.is_a?(LogStash::Event) - event = LogStash::Event.new({ - "@message" => event, - "@type" => @type, - "@tags" => @tags.clone, - "@source" => @url, - }) - end - @logger.debug(["Got event", event]) - @callback.call(event) - end # def receive -end # class LogStash::Inputs::Internal diff --git a/lib/logstash/inputs/tcp.rb b/lib/logstash/inputs/tcp.rb index b5e706423..647e63ebe 100644 --- a/lib/logstash/inputs/tcp.rb +++ b/lib/logstash/inputs/tcp.rb @@ -44,7 +44,7 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base e = LogStash::Event.new({ "@message" => buf, "@type" => @type, - "@tags" => [@type], + "@tags" => @tags.clone, }) e.source = "tcp://#{@host}:#{@port}/client/#{peer}" @logger.debug(["Received message from #{peer}"], e) @@ -63,5 +63,5 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base end # begin end # Thread.start end # loop (outer) - end # def receive + end # def run end # class LogStash::Inputs::Tcp