Class: Fluent::GoogleChatOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::GoogleChatOutput
- Includes:
- SetTagKeyMixin, SetTimeKeyMixin
- Defined in:
- lib/fluent/plugin/out_google_chat.rb
Defined Under Namespace
Classes: Field
Instance Attribute Summary collapse
-
#google_chat ⇒ Object
readonly
for test.
-
#localtime ⇒ Object
readonly
for test.
-
#mrkdwn_in ⇒ Object
readonly
for test.
-
#post_message_opts ⇒ Object
readonly
for test.
-
#time_format ⇒ Object
readonly
for test.
-
#timef ⇒ Object
readonly
for test.
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #desc(description) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ GoogleChatOutput
constructor
A new instance of GoogleChatOutput.
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ GoogleChatOutput
Returns a new instance of GoogleChatOutput.
55 56 57 58 |
# File 'lib/fluent/plugin/out_google_chat.rb', line 55 def initialize super require 'uri' end |
Instance Attribute Details
#google_chat ⇒ Object (readonly)
for test
53 54 55 |
# File 'lib/fluent/plugin/out_google_chat.rb', line 53 def google_chat @google_chat end |
#localtime ⇒ Object (readonly)
for test
53 54 55 |
# File 'lib/fluent/plugin/out_google_chat.rb', line 53 def localtime @localtime end |
#mrkdwn_in ⇒ Object (readonly)
for test
53 54 55 |
# File 'lib/fluent/plugin/out_google_chat.rb', line 53 def mrkdwn_in @mrkdwn_in end |
#post_message_opts ⇒ Object (readonly)
for test
53 54 55 |
# File 'lib/fluent/plugin/out_google_chat.rb', line 53 def @post_message_opts end |
#time_format ⇒ Object (readonly)
for test
53 54 55 |
# File 'lib/fluent/plugin/out_google_chat.rb', line 53 def time_format @time_format end |
#timef ⇒ Object (readonly)
for test
53 54 55 |
# File 'lib/fluent/plugin/out_google_chat.rb', line 53 def timef @timef end |
Instance Method Details
#configure(conf) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/fluent/plugin/out_google_chat.rb', line 60 def configure(conf) conf['time_format'] ||= '%H:%M:%S' # old version compatiblity conf['localtime'] ||= true unless conf['utc'] super if @space @space = URI.unescape(@space) # old version compatibility else raise Fluent::ConfigError.new("`space` is required") end if @keyfile if @keyfile.empty? raise Fluent::ConfigError.new("`keyfile` is an empty string") end if @keyfile.nil? raise Fluent::ConfigError.new("`keyfile` parameter required for Google Chat") end @google_chat = Fluent::GoogleChatClient::WebApi.new(@keyfile) else raise Fluent::ConfigError.new("`keyfile` is required") end @google_chat.log = log @google_chat.debug_dev = log.out if log.level <= Fluent::Log::LEVEL_TRACE if @https_proxy @google_chat.https_proxy = @https_proxy end @message ||= '%s' @message_keys ||= %w[message] begin @message % (['1'] * @message_keys.length) rescue ArgumentError raise Fluent::ConfigError, "string specifier '%s' for `message` and `message_keys` specification mismatch" end if @space_keys begin @space % (['1'] * @space_keys.length) rescue ArgumentError raise Fluent::ConfigError, "string specifier '%s' for `space` and `space_keys` specification mismatch" end end end |
#desc(description) ⇒ Object
11 12 |
# File 'lib/fluent/plugin/out_google_chat.rb', line 11 def desc(description) end |
#format(tag, time, record) ⇒ Object
106 107 108 |
# File 'lib/fluent/plugin/out_google_chat.rb', line 106 def format(tag, time, record) [tag, time, record].to_msgpack end |
#write(chunk) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/fluent/plugin/out_google_chat.rb', line 110 def write(chunk) begin payloads = build_payloads(chunk) payloads.each {|payload| @google_chat.(payload) } rescue Timeout::Error => e log.warn "out_google_chat:", :error => e.to_s, :error_class => e.class.to_s raise e # let Fluentd retry rescue => e log.error "out_google_chat:", :error => e.to_s, :error_class => e.class.to_s log.warn_backtrace e.backtrace # discard. @todo: add more retriable errors end end |