Class: Fluent::BufferedHipchatOutput
- Inherits:
-
TimeSlicedOutput
- Object
- TimeSlicedOutput
- Fluent::BufferedHipchatOutput
- Defined in:
- lib/fluent/plugin/out_buffered_hipchat.rb
Instance Attribute Summary collapse
-
#hipchat ⇒ Object
readonly
Returns the value of attribute hipchat.
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ BufferedHipchatOutput
constructor
A new instance of BufferedHipchatOutput.
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ BufferedHipchatOutput
Returns a new instance of BufferedHipchatOutput.
44 45 46 47 |
# File 'lib/fluent/plugin/out_buffered_hipchat.rb', line 44 def initialize super require 'hipchat-api' end |
Instance Attribute Details
#hipchat ⇒ Object (readonly)
Returns the value of attribute hipchat.
15 16 17 |
# File 'lib/fluent/plugin/out_buffered_hipchat.rb', line 15 def hipchat @hipchat end |
Instance Method Details
#configure(conf) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fluent/plugin/out_buffered_hipchat.rb', line 49 def configure(conf) super @hipchat = HipChat::API.new(conf['api_token']) @default_room = conf['default_room'] @default_from = conf['default_from'] || 'fluentd' @default_notify = conf['default_notify'] || 0 @default_color = conf['default_color'] || 'yellow' @default_format = conf['default_format'] || 'html' if conf['http_proxy_host'] HipChat::API.http_proxy( conf['http_proxy_host'], conf['http_proxy_port'], conf['http_proxy_user'], conf['http_proxy_pass']) end end |
#format(tag, time, record) ⇒ Object
17 18 19 |
# File 'lib/fluent/plugin/out_buffered_hipchat.rb', line 17 def format(tag, time, record) [tag, time, record].to_json + "\n" end |
#write(chunk) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fluent/plugin/out_buffered_hipchat.rb', line 21 def write(chunk) = {} chunk.open {|io| io.each {|line| line_json = JSON.parse(line) tag = line_json[0] time = line_json[1] record = line_json[2] [tag] = '' unless [tag] [tag] << "[#{Time.at(time)}] #{record['message']}\n" } } # hoge = "ajshdfjalksfjlkasdjf\nlaksjfdl\naksfksadflka;" # hoge.scan(/.{1,24}\Z|.{1,24}\n/m) .each do |tag, | .scan(/.{1,9500}/m).each {|| @hipchat.(@default_room, @default_from, "#{tag} >>\n" + , @default_notify, @default_color, @default_format) } end rescue => e $log.error("HipChat Error: #{e} / #{e.}") end |