fluent-plugin-heroku-syslog-http 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 532357c0144bd00b49441c441a413a1418857f42
4
- data.tar.gz: 7d0804f14d7d041736c35d986f8c0db2fd6e34a8
3
+ metadata.gz: 0624c9d73582304ed077c39803d7350b425838c1
4
+ data.tar.gz: 339dc0f4a5166fe2d581e8524839c26e1606de76
5
5
  SHA512:
6
- metadata.gz: fad8aed05a98d60e1e684ea0b9b3e99cdefcd296003a536d910ef0597fe77839b2c01f3fa3a0cfff2322209f6b5143b3d1ca3cde172ffd297d9c06440a1f6e62
7
- data.tar.gz: 73df938e9c8a26fc7f53601631d633f5c4e852caf8973dd763f42f9f40b28a92e0c8d6fa173b834c8d561ff064672064903b0f32c027372042ada494fb50ded0
6
+ metadata.gz: ba3a89f11e524c6bc440c686ee76741a79af6f041199b156deed30607b6a26d87886ef151e7ff566b2e5c48d451fcfa7eb40d6228c11abcc33eb53f9d94d76fb
7
+ data.tar.gz: de9383bd19a6f5f7016626b83ac63c32d30217263f769f927eb30ac2164074a3ec5807b7a096e9eae74d541ae21ab9eb573d1ff9389aa2e2bf6338cd094874df
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'fluent-plugin-heroku-syslog-http'
5
- gem.version = '0.2.1'
5
+ gem.version = '0.2.2'
6
6
  gem.authors = ['Drivy', 'Kazuyuki Honda']
7
7
  gem.email = ['sre@drivy.com']
8
8
  gem.description = 'fluent plugin to drain heroku syslog'
@@ -19,15 +19,14 @@ module Fluent
19
19
  raise "'#{EVENT_RECORD_PARAMETER}' parameter is required" unless content
20
20
 
21
21
  messages = []
22
- while payload = content.match(/^([0-9]+) (.*)$/) do
22
+ while payload = content.match(/^([0-9]+) (.*)$/m) do
23
23
  length = payload[1].to_i
24
- raise "Invalid message length specified: #{length}" unless payload[2].size >= length
24
+ log.warn "Invalid message length specified: #{length}" unless payload[2].size >= length
25
25
 
26
26
  messages << payload[2][0...length]
27
27
  content = payload[2][length..-1] || ''
28
28
  end
29
- content << content
30
- raise "#{content.size} bytes left in payload" unless content.size == 0
29
+ log.warn "#{content.size} bytes left in payload" unless content.size == 0
31
30
 
32
31
  records = []
33
32
  messages.each do |msg|
@@ -8,7 +8,7 @@ module Fluent
8
8
  class HerokuSyslogHttpParser < RegexpParser
9
9
  Fluent::Plugin.register_parser('heroku_syslog_http', self)
10
10
 
11
- SYSLOG_HTTP_REGEXP = %r{^\<(?<syslog.pri>[0-9]+)\>([0-9]+) (?<syslog.timestamp>[^ ]+) (?<syslog.hostname>[^ ]+) (?<syslog.appname>[^ ]+) (?<syslog.procid>[^ ]+) - *(?<message>.*)$}
11
+ SYSLOG_HTTP_REGEXP = %r{^\<(?<syslog.pri>[0-9]+)\>([0-9]+) (?<syslog.timestamp>[^ ]+) (?<syslog.hostname>[^ ]+) (?<syslog.appname>[^ ]+) (?<syslog.procid>[^ ]+) - *(?<message>.*)$}m
12
12
 
13
13
  FACILITY_MAP = {
14
14
  0 => 'kern',
@@ -81,6 +81,22 @@ class HerokuSyslogHttpInputTest < Test::Unit::TestCase
81
81
  assert_equal 'x' * 1024, d.events[1][2]['message']
82
82
  end
83
83
 
84
+ def test_newlines_in_payload
85
+ messages = [
86
+ "60 <13>1 2014-01-29T06:25:52.589365+00:00 host app web.1 - foo\n",
87
+ "60 <13>1 2014-01-29T06:25:52.589365+00:00 host app web.1 - bar\n",
88
+ ]
89
+ d = create_driver
90
+ d.run(expect_records: 1, timeout: 5) do
91
+ res = post(messages)
92
+ assert_equal '', res.body
93
+ assert_equal '200', res.code
94
+ end
95
+
96
+ assert_equal "foo\n", d.events[0][2]['message']
97
+ assert_equal "bar\n", d.events[1][2]['message']
98
+ end
99
+
84
100
  def test_accept_matched_drain_id_multiple
85
101
  messages = [
86
102
  '59 <13>1 2014-01-01T01:23:45.123456+00:00 host app web.1 - foo',
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-heroku-syslog-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drivy