logstash-codec-line 2.0.2 → 2.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: 84d9d0ba0a6de9a1bcde8b3c4e7953beaa055050
4
- data.tar.gz: 5f3fbc68aa4fdf03ddf8d522f3736fbc1e7caba4
3
+ metadata.gz: 701c6951b1e5021efc5e76849dffd39d08b895d9
4
+ data.tar.gz: ff6c1850a1c0228f1607f207d3240f497ac6d21f
5
5
  SHA512:
6
- metadata.gz: 85ebe2fbfcadfb52fed934e4ae9035686374d8ad7e128772cce69b650290f00fb77cc7402af17979b4c4698b940ab21c5153cbadca22645a53ea8fa58d7e9bfa
7
- data.tar.gz: 551546a98206a72a99dd8ae5362b06989fc2ef0cb31676b6506cfa6d59ae1718061e0fd959896559af0290dda7606765e0512c53c32c417aa6376f84f0698e95
6
+ metadata.gz: d35c45d1f26991aa71eaac0f6b2179063fd3abfc598015bb2d1c097401f257b846c5cf12cf77683e4f6ca25bdf1e696cbc009f429c690881233b035b29c2e02a
7
+ data.tar.gz: 3c65173b48bfe947fcb9f269a21a49a542802883ebf5f0b7c6e6da934c4fa6c3346bc99b2dd76548b28691e471324865d7a8d5d34aa579f1e111c4d00bd819ae
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 2.1.0
2
+ - Support the customization of the delimiter through :delimiter option
3
+
1
4
  ## 2.0.0
2
5
  - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
3
6
  instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Logstash Plugin
2
2
 
3
+ [![Build
4
+ Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Codecs/job/logstash-plugin-codec-line-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Codecs/job/logstash-plugin-codec-line-unit/)
5
+
3
6
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
7
 
5
8
  It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
@@ -22,10 +22,13 @@ class LogStash::Codecs::Line < LogStash::Codecs::Base
22
22
  # This only affects "plain" format logs since json is `UTF-8` already.
23
23
  config :charset, :validate => ::Encoding.name_list, :default => "UTF-8"
24
24
 
25
+ # Change the delimiter that separates lines
26
+ config :delimiter, :validate => :string, :default => "\n"
27
+
25
28
  public
26
29
  def register
27
30
  require "logstash/util/buftok"
28
- @buffer = FileWatch::BufferedTokenizer.new
31
+ @buffer = FileWatch::BufferedTokenizer.new(@delimiter)
29
32
  @converter = LogStash::Util::Charset.new(@charset)
30
33
  @converter.logger = @logger
31
34
  end
@@ -48,9 +51,9 @@ class LogStash::Codecs::Line < LogStash::Codecs::Base
48
51
  public
49
52
  def encode(event)
50
53
  if event.is_a? LogStash::Event and @format
51
- @on_event.call(event, event.sprintf(@format) + NL)
54
+ @on_event.call(event, event.sprintf(@format) + @delimiter)
52
55
  else
53
- @on_event.call(event, event.to_s + NL)
56
+ @on_event.call(event, event.to_s + @delimiter)
54
57
  end
55
58
  end # def encode
56
59
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-codec-line'
4
- s.version = '2.0.2'
4
+ s.version = '2.1.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Line-oriented text data."
7
7
  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"
@@ -29,6 +29,20 @@ describe LogStash::Codecs::Line do
29
29
  end
30
30
  subject.encode(event)
31
31
  end
32
+
33
+ context "when using custom :delimiter" do
34
+ subject do
35
+ next LogStash::Codecs::Line.new("delimiter" => "|")
36
+ end
37
+
38
+ it "should append the delimiter to the line" do
39
+ expect(subject).to receive(:on_event).once.and_call_original
40
+ subject.on_event do |e, d|
41
+ insist {d} == event.to_s + "|"
42
+ end
43
+ subject.encode(event)
44
+ end
45
+ end
32
46
  end
33
47
 
34
48
  context "#decode" do
@@ -48,6 +62,31 @@ describe LogStash::Codecs::Line do
48
62
  insist { e["message"] } == "München"
49
63
  end
50
64
  end
65
+
66
+ context "when using custom :delimiter" do
67
+ subject do
68
+ next LogStash::Codecs::Line.new("delimiter" => "|")
69
+ end
70
+
71
+ it "should not break lines by '\n'" do
72
+ line = "line1\nline2\nline3\n"
73
+ result = []
74
+ subject.decode(line) { |e| result << e }
75
+ subject.flush { |e| result << e }
76
+ expect(result.size).to eq(1)
77
+ expect(result[0]["message"]).to eq(line)
78
+ end
79
+
80
+ it "should break lines by that delimiter" do
81
+ result = []
82
+ subject.decode("line1|line2|line3|") { |e| result << e }
83
+ subject.flush { |e| result << e }
84
+ expect(result.size).to eq(3)
85
+ expect(result[0]["message"]).to eq("line1")
86
+ expect(result[1]["message"]).to eq("line2")
87
+ expect(result[2]["message"]).to eq("line3")
88
+ end
89
+ end
51
90
  end
52
91
 
53
92
  context "#flush" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-codec-line
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-14 00:00:00.000000000 Z
11
+ date: 2016-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement