- Support ruby 1.9

This commit is contained in:
Jordan Sissel 2009-08-18 19:47:05 +00:00
parent 7b83c35eaf
commit 46c4feb300
4 changed files with 15 additions and 4 deletions

View file

@ -21,18 +21,19 @@ class Agent < LogStash::Net::MessageClient
end # def initialize
def start_log_watcher
Thread.new do
@t1 = Thread.new do
File::Tail::Since.new("/var/log/messages").tail do |line|
line.chomp!
index("linux-syslog", line)
end
end
Thread.new do
@t2 = Thread.new do
File::Tail::Since.new("/b/access").tail do |line|
line.chomp!
index("httpd-access", line)
end
exit
end
end # def start_log_watcher

View file

@ -25,3 +25,11 @@ class String
alias_method :checksum, :adler32
end # class String
# EventMachine uses ruby1.8 (not in 1.9) function Thread#kill!,
# so let's fake it.
class Thread
def kill!(*args)
kill
end
end

View file

@ -30,7 +30,9 @@ module BindToHash
if value.is_a?(String)
(0 .. value.length - 1).each do |i|
break if !value[i]
if value[i] >= 128
# ruby 1.9 String#[] returns a string, 1.8 returns an int
# force an int.
if value[i].to_i >= 128
value[i] = ""
end
end

View file

@ -32,7 +32,7 @@ module LogStash; module Net
name = msg.class.name.split(":")[-1]
func = "#{name}Handler"
if @handler.respond_to?(func):
if @handler.respond_to?(func)
#operation = lambda do
#@handler.send(func, msg) do |response|
#sendmsg(response)