logstash-codec-form 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00bad5d41ade7457f0b0dc3b085e93ed430b52d1
4
- data.tar.gz: 4751fda129d80c4afe4ea463f325f838da97e00e
3
+ metadata.gz: bfcf038963d59e55a83ea30b52c96b5bfbb6a9ea
4
+ data.tar.gz: 056c57a5f14af66f7b8eef42af690abce74c5e91
5
5
  SHA512:
6
- metadata.gz: c1d737ee02bf967d2123457450479f097e88c633b8c2ec4added347d4c452296c5f95966d3d7de8cc191ed69b6b4afe4f6c0f055eef60327b896dc8598c2f104
7
- data.tar.gz: 9bca7fbf432c81c7526e663d7eac93e4beb6dfc520c39a9866f84a3e9c12b11f7dd4593ba590ea81ba8aa26504b4c2940aeebbe03f19cf75bff3527ab55e4906
6
+ metadata.gz: 5d653f3053739345765d5a243cc43282a8e375c6e3d0ac6916ad6876e275a09695208aca4b186f5677cccfc535a1a3cff3d8634b700646c6352679eaacd8343d
7
+ data.tar.gz: f5fa54a7d428fb12c58571d5144b3bc76404b95d2f58aaf819307f7dedccf2586e878cfbed40e9846397d5782db4785fd254740e825b842fe5ede6e789d84639
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ ## 1.1.0 - January 21 2016
2
+
3
+ * Replace `LogStash::Codecs::Line` with `LogStash::Util::Charset` for initial
4
+ handling of the message.
5
+ * Add logging and error handling around form parsing.
6
+
7
+ ## 1.0.0 - January 21 2016
8
+
9
+ * Initial release
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require 'logstash/codecs/base'
3
- require 'logstash/codecs/line'
3
+ require 'logstash/util/charset'
4
4
  require 'uri'
5
5
 
6
6
  class LogStash::Codecs::Form < LogStash::Codecs::Base
@@ -29,10 +29,13 @@ class LogStash::Codecs::Form < LogStash::Codecs::Base
29
29
  # }
30
30
  config_name 'form'
31
31
 
32
+ # The character encoding used in this codec. Defaults to "UTF-8".
33
+ config :charset, validate: ::Encoding.name_list, default: "UTF-8"
34
+
32
35
  private
33
- def parse(line)
36
+ def parse(payload)
34
37
  event = {}
35
- keypairs = URI.decode_www_form(line['message'])
38
+ keypairs = URI.decode_www_form payload
36
39
  keypairs.each do |keypair|
37
40
  if event.has_key? keypair[0]
38
41
  event[keypair[0]] << keypair[1]
@@ -45,19 +48,31 @@ class LogStash::Codecs::Form < LogStash::Codecs::Base
45
48
 
46
49
  private
47
50
  def dump(event)
48
- URI.encode_www_form(event.to_hash) + NL
51
+ URI.encode_www_form event.to_hash
49
52
  end
50
53
 
51
54
  public
52
55
  def register
53
- @lines = LogStash::Codecs::Line.new
54
- @lines.charset = 'UTF-8'
56
+ @converter = LogStash::Util::Charset.new @charset
57
+ @converter.logger = @logger
55
58
  end
56
59
 
57
60
  public
58
61
  def decode(payload)
59
- @lines.decode(payload) do |line|
60
- yield LogStash::Event.new(parse(line))
62
+ payload = @converter.convert payload
63
+ begin
64
+ yield LogStash::Event.new(parse(payload))
65
+ rescue StandardError => e
66
+ @logger.warn(
67
+ "An unexpected error occurred",
68
+ message: e.message,
69
+ backtrace: e.backtrace,
70
+ input: payload
71
+ )
72
+ yield LogStash::Event.new(
73
+ "message" => payload,
74
+ "tags" => ["_formparsefailure"]
75
+ )
61
76
  end
62
77
  end
63
78
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-codec-form'
3
- s.version = '1.0.0'
3
+ s.version = '1.1.0'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Read or write events in a application/x-www-form-urlencoded format."
6
6
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program."
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
20
20
 
21
21
  # Gem dependencies
22
22
  s.add_runtime_dependency "logstash-core", ">= 2.0.0.beta2", "< 3.0.0"
23
- s.add_runtime_dependency "logstash-codec-line", "~> 2.0", ">= 2.0.2"
24
23
 
25
24
  s.add_development_dependency 'logstash-devutils'
26
25
  end
@@ -17,7 +17,7 @@ describe LogStash::Codecs::Form do
17
17
  it 'should return an application/x-www-form-urlencoded formatted line' do
18
18
  expect(subject).to receive(:on_event).once.and_call_original
19
19
  subject.on_event do |e, d|
20
- insist {d} == "message=hello+world&host=test&%40version=1&%40timestamp=#{URI.encode_www_form_component(event.timestamp)}\n"
20
+ insist {d} == "message=hello+world&host=test&%40version=1&%40timestamp=#{URI.encode_www_form_component(event.timestamp)}"
21
21
  end
22
22
  subject.encode(event)
23
23
  end
@@ -26,7 +26,7 @@ describe LogStash::Codecs::Form do
26
26
  context '#decode' do
27
27
  it 'should return an event from an application/x-www-form-urlencoded string' do
28
28
  decoded = false
29
- subject.decode("message=hello+world&host=test\n") do |e|
29
+ subject.decode("message=hello+world&host=test") do |e|
30
30
  decoded = true
31
31
  insist { e.is_a?(LogStash::Event) }
32
32
  insist { e['message'] } == ['hello world']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-codec-form
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brendan ODonnell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-21 00:00:00.000000000 Z
11
+ date: 2016-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -30,26 +30,6 @@ dependencies:
30
30
  - - <
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.0.0
33
- - !ruby/object:Gem::Dependency
34
- requirement: !ruby/object:Gem::Requirement
35
- requirements:
36
- - - ~>
37
- - !ruby/object:Gem::Version
38
- version: '2.0'
39
- - - '>='
40
- - !ruby/object:Gem::Version
41
- version: 2.0.2
42
- name: logstash-codec-line
43
- prerelease: false
44
- type: :runtime
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ~>
48
- - !ruby/object:Gem::Version
49
- version: '2.0'
50
- - - '>='
51
- - !ruby/object:Gem::Version
52
- version: 2.0.2
53
33
  - !ruby/object:Gem::Dependency
54
34
  requirement: !ruby/object:Gem::Requirement
55
35
  requirements:
@@ -70,6 +50,7 @@ executables: []
70
50
  extensions: []
71
51
  extra_rdoc_files: []
72
52
  files:
53
+ - CHANGELOG.md
73
54
  - Gemfile
74
55
  - LICENSE
75
56
  - NOTICE.TXT