From a6a367460ee61e8c50d2039b42fe26442e5507f3 Mon Sep 17 00:00:00 2001 From: Pete Fritchman Date: Sat, 26 Feb 2011 19:46:07 -0800 Subject: [PATCH 1/4] keep @tags working and remove unnecessary def receive --- lib/logstash/inputs/base.rb | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/logstash/inputs/base.rb b/lib/logstash/inputs/base.rb index cf97e9daf..7696b611d 100644 --- a/lib/logstash/inputs/base.rb +++ b/lib/logstash/inputs/base.rb @@ -11,7 +11,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 +26,8 @@ class LogStash::Inputs::Base def initialize(params) @logger = LogStash::Logger.new(STDERR) config_init(params) + + @tags ||= [] end # def initialize public @@ -37,13 +39,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 From 11c7804848864fd7fba30664ea0bf431b8d82639 Mon Sep 17 00:00:00 2001 From: Pete Fritchman Date: Sat, 26 Feb 2011 19:53:21 -0800 Subject: [PATCH 2/4] use @tags when making an event --- lib/logstash/inputs/tcp.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From ab69c909cde5e778f7fc9134c732cb85ae027c11 Mon Sep 17 00:00:00 2001 From: Pete Fritchman Date: Sat, 26 Feb 2011 19:56:01 -0800 Subject: [PATCH 3/4] remove unnecessary require --- lib/logstash/inputs/base.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/logstash/inputs/base.rb b/lib/logstash/inputs/base.rb index 7696b611d..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 From 702a96fd28743ba6b43510ce52228bd260d8fa27 Mon Sep 17 00:00:00 2001 From: Pete Fritchman Date: Sat, 26 Feb 2011 20:00:18 -0800 Subject: [PATCH 4/4] going to move this functionality to LogStash::Agent --- lib/logstash/inputs/internal.rb | 42 --------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 lib/logstash/inputs/internal.rb 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