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 +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +3 -0
- data/lib/logstash/codecs/line.rb +6 -3
- data/logstash-codec-line.gemspec +1 -1
- data/spec/codecs/line_spec.rb +39 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 701c6951b1e5021efc5e76849dffd39d08b895d9
|
4
|
+
data.tar.gz: ff6c1850a1c0228f1607f207d3240f497ac6d21f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/lib/logstash/codecs/line.rb
CHANGED
@@ -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) +
|
54
|
+
@on_event.call(event, event.sprintf(@format) + @delimiter)
|
52
55
|
else
|
53
|
-
@on_event.call(event, event.to_s +
|
56
|
+
@on_event.call(event, event.to_s + @delimiter)
|
54
57
|
end
|
55
58
|
end # def encode
|
56
59
|
|
data/logstash-codec-line.gemspec
CHANGED
@@ -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
|
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"
|
data/spec/codecs/line_spec.rb
CHANGED
@@ -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
|
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:
|
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
|