mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
Merge branch 'master' of github.com:logstash/logstash
This commit is contained in:
commit
4951e155fd
3 changed files with 5 additions and 55 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue