From b3ccedc34a1a0a2c007cf833ab62da1f3f47700a Mon Sep 17 00:00:00 2001 From: Lance O'Connor Date: Mon, 24 Feb 2014 20:35:07 +0000 Subject: [PATCH] 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] This is a pre message [12:32] This is the actual message [12:32] 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.) --- lib/logstash/outputs/irc.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/logstash/outputs/irc.rb b/lib/logstash/outputs/irc.rb index cd1d527db..99687d4c7 100644 --- a/lib/logstash/outputs/irc.rb +++ b/lib/logstash/outputs/irc.rb @@ -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