31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/fluent/plugin/out_line_notify.rb', line 31
def emit(tag, es, chain)
es.each do |time, record|
t = Templater.new
t.tag = tag
t.time = time
t.record = record
msg = t.result(@erb)
begin
resp = HTTParty.post(
@api_url,
headers: {
'Authorization' => "Bearer #{@access_token}",
'Content-Type' => 'application/x-www-form-urlencoded',
},
body: "message=#{CGI.escape(msg)}"
)
raise resp.message if resp.code != 200
rescue
$log.warn "raises exception: #{$!.class}, '#{$!.message}, #{t}'"
end
end
chain.next
end
|