Class: Fluent::IRCOutput

Inherits:
Output
  • Object
show all
Includes:
SetTagKeyMixin, SetTimeKeyMixin
Defined in:
lib/fluent/plugin/out_irc.rb

Defined Under Namespace

Classes: IRCConnection

Instance Method Summary collapse

Constructor Details

#initializeIRCOutput

Returns a new instance of IRCOutput.



27
28
29
30
# File 'lib/fluent/plugin/out_irc.rb', line 27

def initialize
  super
  require 'irc_parser'
end

Instance Method Details

#configure(conf) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/fluent/plugin/out_irc.rb', line 32

def configure(conf)
  super
  begin
    @message % (['1'] * @out_keys.length)
  rescue ArgumentError
    raise Fluent::ConfigError, "string specifier '%s' and out_keys specification mismatch"
  end
end

#emit(tag, es, chain) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fluent/plugin/out_irc.rb', line 56

def emit(tag, es, chain)
  chain.next

  if @conn.closed?
    refresh_connection(@conn)
  end

  es.each do |time,record|
    filter_record(tag, time, record)
    @conn.send_message(build_message(record))
  end
end

#shutdownObject



51
52
53
54
# File 'lib/fluent/plugin/out_irc.rb', line 51

def shutdown
  super
  @conn.close unless @conn.closed?
end

#startObject



41
42
43
44
45
46
47
48
49
# File 'lib/fluent/plugin/out_irc.rb', line 41

def start
  super

  begin
    @conn = create_connection
  rescue
    raise Fluent::ConfigError, "failto connect IRC server #{@host}:#{@port}"
  end
end