Class: LogStash::Inputs::Irc
- Defined in:
- lib/logstash/inputs/irc.rb
Overview
Read events from an IRC Server.
Constant Summary
Constants included from Config::Mixin
Instance Attribute Summary
Attributes inherited from Base
Attributes included from Config::Mixin
Attributes inherited from Plugin
Instance Method Summary collapse
Methods inherited from Base
Methods included from Config::Mixin
Methods inherited from Plugin
#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s
Constructor Details
This class inherits a constructor from LogStash::Inputs::Base
Instance Method Details
#register ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/logstash/inputs/irc.rb', line 43 def register require "cinch" @irc_queue = Queue.new @logger.info("Connecting to irc server", :host => @host, :port => @port, :nick => @nick, :channels => @channels) @bot = Cinch::Bot.new @bot.loggers.clear @bot.configure do |c| c.server = @host c.port = @port c.nick = @nick c.user = @user c.realname = @real c.channels = @channels c.password = @password.value rescue nil c.ssl.use = @secure end queue = @irc_queue @bot.on :channel do |m| queue << m end end |
#run(output_queue) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/logstash/inputs/irc.rb', line 67 def run(output_queue) Thread.new(@bot) do |bot| bot.start end loop do msg = @irc_queue.pop if msg.user @codec.decode(msg.) do |event| decorate(event) event["channel"] = msg.channel.to_s event["nick"] = msg.user.nick event["server"] = "#{@host}:#{@port}" output_queue << event end end end end |