mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
Close LOGSTASH-1933:
Add two (2) new config stanzas to IRC output: pre_string: Message you want emitted to IRC server before the event text post_string: Message you want emitted to the IRC server after the event text [12:32] <logstash> This is a pre message [12:32] <logstash> This is the actual message [12:32] <logstash> Tis is a post message In both cases, they are sent as seperate messages to the IRC server, leaving the event text unmodified. (N.B. My 1st real modification to the ruby codebase, so someone who knows ruby should really validate I did this correctly.)
This commit is contained in:
parent
b730a7f95d
commit
b3ccedc34a
1 changed files with 12 additions and 0 deletions
|
@ -43,6 +43,12 @@ class LogStash::Outputs::Irc < LogStash::Outputs::Base
|
|||
# Limit the rate of messages sent to IRC in messages per second.
|
||||
config :messages_per_second, :validate => :number, :default => 0.5
|
||||
|
||||
# Static string before event
|
||||
config :pre_string, :validate => :string, :required => false
|
||||
|
||||
# Static string before event
|
||||
config :post_string, :validate => :string, :required => false
|
||||
|
||||
public
|
||||
def register
|
||||
require "cinch"
|
||||
|
@ -74,7 +80,13 @@ class LogStash::Outputs::Irc < LogStash::Outputs::Base
|
|||
text = event.sprintf(@format)
|
||||
@bot.channels.each do |channel|
|
||||
@logger.debug("Sending to...", :channel => channel, :text => text)
|
||||
if !@pre_string.nil?
|
||||
channel.msg(pre_string)
|
||||
end
|
||||
channel.msg(text)
|
||||
if !@post_string.nil?
|
||||
channel.msg(post_string)
|
||||
end
|
||||
end # channels.each
|
||||
end # def receive
|
||||
end # class LogStash::Outputs::Irc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue