logstash-codec-multiline 2.0.5 → 2.0.6

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: ad1702d90e9bf8fb69ffd334989def88c34b8afa
4
- data.tar.gz: dc3b95f3bac523a85107eeb5c0142f6687a09b25
3
+ metadata.gz: bb29402e4fc64969af12f38713f553e18dc57418
4
+ data.tar.gz: f8a9fb89870cc25e7a252b11c47e7c5e5dc94eb7
5
5
  SHA512:
6
- metadata.gz: f29daf9944841236fd22a7c4dfe80a3fa7f4ba3efd3e06809cc35d8b8345b7e691aec1695413bcbc1a4f288feceb923ed4798ff1eec8f5ea710b29fbd97915f5
7
- data.tar.gz: 3ba39d672418818e50deafc4f24c9d6ca9196eada5b88ca884c406eafcfdb0e4d6c9650418071623d2a229e675346ac8d0f8205f902a6b298c3f8e70e727ab2c
6
+ metadata.gz: 89e537074ac1b46b495e0ae0a926abed3a9609ef906f519e70b3b68753b4ecdebb6e4ef04cd8d926a535fc65ac2335677b85cba500d5061dbbe9e8c68364aaca
7
+ data.tar.gz: 76e16b208297f0bbeb47bb8f00daabd8b89017d7a4181478e06e72b19bfa73c99e7065ad6cc9e229786d772298c7eb0eea936f68f953aa3cbdb62ce42f12a690
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 2.0.6
2
+ - Isolate spec helper classes in their own namespace.
3
+
1
4
  ## 2.0.5
2
5
  - Add auto_flush config option, with no default. If not set, no auto_flush is done.
3
6
  - Add evict method to identity_map_codec that allows for an input, when done with an identity, to auto_flush and remove the identity from the map.
data/CONTRIBUTORS CHANGED
@@ -9,6 +9,7 @@ Contributors:
9
9
  * Pier-Hugues Pellerin (ph)
10
10
  * Richard Pijnenburg (electrical)
11
11
  * Suyog Rao (suyograo)
12
+ * Guy Boertje (guyboertje)
12
13
 
13
14
  Note: If you've sent us patches, bug reports, or otherwise contributed to
14
15
  Logstash, and you aren't on the list above and want to be, please let us know
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-codec-multiline'
4
- s.version = '2.0.5'
4
+ s.version = '2.0.6'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "The multiline codec will collapse multiline messages and merge them into a single event."
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"
@@ -4,7 +4,7 @@ require "logstash/codecs/multiline"
4
4
  require_relative "../supports/helpers.rb"
5
5
 
6
6
  describe "AutoFlush and AutoFlushUnset" do
7
- let(:flushable) { AutoFlushTracer.new }
7
+ let(:flushable) { Mlc::AutoFlushTracer.new }
8
8
  let(:flush_wait) { 0.1 }
9
9
 
10
10
  describe LogStash::Codecs::AutoFlush do
@@ -5,7 +5,7 @@ require "logstash/codecs/multiline"
5
5
  require_relative "../supports/helpers.rb"
6
6
 
7
7
  describe LogStash::Codecs::IdentityMapCodec do
8
- let(:codec) { IdentityMapCodecTracer.new }
8
+ let(:codec) { Mlc::IdentityMapCodecTracer.new }
9
9
  let(:logger) { codec.logger }
10
10
  let(:demuxer) { described_class.new(codec) }
11
11
  let(:stream1) { "stream-a" }
@@ -198,15 +198,15 @@ describe LogStash::Codecs::IdentityMapCodec do
198
198
  end
199
199
 
200
200
  describe "observer/listener based processing" do
201
- let(:listener) { LineListener }
201
+ let(:listener) { Mlc::LineListener }
202
202
  let(:queue) { [] }
203
203
  let(:identity) { "stream1" }
204
204
  let(:config) { {"pattern" => "^\\s", "what" => "previous"} }
205
- let(:mlc) { MultilineRspec.new(config).tap {|c| c.register } }
205
+ let(:mlc) { Mlc::MultilineRspec.new(config).tap {|c| c.register } }
206
206
  let(:imc) { described_class.new(mlc) }
207
207
 
208
208
  before do
209
- listener = LineListener.new(queue, imc, identity)
209
+ listener = Mlc::LineListener.new(queue, imc, identity)
210
210
  listener.accept("foo")
211
211
  end
212
212
 
@@ -217,14 +217,14 @@ describe LogStash::Codecs::Multiline do
217
217
 
218
218
  describe "auto flushing" do
219
219
  let(:config) { {} }
220
- let(:codec) { MultilineRspec.new(config).tap {|c| c.register} }
220
+ let(:codec) { Mlc::MultilineRspec.new(config).tap {|c| c.register} }
221
221
  let(:events) { [] }
222
222
  let(:lines) do
223
223
  { "en.log" => ["hello world", " second line", " third line"],
224
224
  "fr.log" => ["Salut le Monde", " deuxième ligne", " troisième ligne"],
225
225
  "de.log" => ["Hallo Welt"] }
226
226
  end
227
- let(:listener_class) { LineListener }
227
+ let(:listener_class) { Mlc::LineListener }
228
228
  let(:auto_flush_interval) { 0.5 }
229
229
 
230
230
  let(:line_producer) do
@@ -249,12 +249,12 @@ describe LogStash::Codecs::Multiline do
249
249
 
250
250
  context "when the auto_flush raises an exception" do
251
251
  let(:errmsg) { "OMG, Daleks!" }
252
- let(:listener_class) { LineErrorListener }
252
+ let(:listener_class) { Mlc::LineErrorListener }
253
253
 
254
254
  it "does not build any events, logs an error and the buffer data remains" do
255
255
  config.update("pattern" => "^\\s", "what" => "previous",
256
256
  "auto_flush_interval" => auto_flush_interval)
257
- codec.logger = MultilineLogTracer.new
257
+ codec.logger = Mlc::MultilineLogTracer.new
258
258
  line_producer.call("en.log")
259
259
  sleep(auto_flush_interval + 0.1)
260
260
  msg, args = codec.logger.trace_for(:error)
@@ -13,95 +13,97 @@ def decode_events
13
13
  events
14
14
  end
15
15
 
16
- class LineListener
17
- attr_reader :data, :path, :queue, :codec
18
- # use attr_reader to define noop methods of Listener API
19
- attr_reader :deleted, :created, :error, :eof #, :line
20
-
21
- def initialize(queue, codec, path = '')
22
- # store state from upstream
23
- @queue = queue
24
- @codec = codec
25
- @path = path
16
+ module Mlc
17
+ class LineListener
18
+ attr_reader :data, :path, :queue, :codec
19
+ # use attr_reader to define noop methods of Listener API
20
+ attr_reader :deleted, :created, :error, :eof #, :line
21
+
22
+ def initialize(queue, codec, path = '')
23
+ # store state from upstream
24
+ @queue = queue
25
+ @codec = codec
26
+ @path = path
27
+ end
28
+
29
+ # receives a line from some upstream source
30
+ # and sends it downstream
31
+ def accept(data)
32
+ @codec.accept dup_adding_state(data)
33
+ end
34
+
35
+ def process_event(event)
36
+ event["path"] = path
37
+ @queue << event
38
+ end
39
+
40
+ def add_state(data)
41
+ @data = data
42
+ self
43
+ end
44
+
45
+ private
46
+
47
+ # dup and add state for downstream
48
+ def dup_adding_state(line)
49
+ self.class.new(queue, codec, path).add_state(line)
50
+ end
26
51
  end
27
52
 
28
- # receives a line from some upstream source
29
- # and sends it downstream
30
- def accept(data)
31
- @codec.accept dup_adding_state(data)
53
+ class LineErrorListener < LineListener
54
+ def process_event(event)
55
+ raise StandardError.new("OMG, Daleks!")
56
+ end
32
57
  end
33
58
 
34
- def process_event(event)
35
- event["path"] = path
36
- @queue << event
59
+ class MultilineRspec < LogStash::Codecs::Multiline
60
+ def internal_buffer
61
+ @buffer
62
+ end
63
+ def buffer_size
64
+ @buffer.size
65
+ end
37
66
  end
38
67
 
39
- def add_state(data)
40
- @data = data
41
- self
42
- end
68
+ class TracerBase
69
+ def initialize() @tracer = []; end
43
70
 
44
- private
71
+ def trace_for(symbol)
72
+ params = @tracer.assoc(symbol)
73
+ params.nil? ? false : params.last
74
+ end
45
75
 
46
- # dup and add state for downstream
47
- def dup_adding_state(line)
48
- self.class.new(queue, codec, path).add_state(line)
76
+ def clear()
77
+ @tracer.clear()
78
+ end
49
79
  end
50
- end
51
80
 
52
- class LineErrorListener < LineListener
53
- def process_event(event)
54
- raise StandardError.new("OMG, Daleks!")
55
- end
56
- end
81
+ class MultilineLogTracer < TracerBase
82
+ def warn(*args) @tracer.push [:warn, args]; end
83
+ def error(*args) @tracer.push [:error, args]; end
84
+ def debug(*args) @tracer.push [:debug, args]; end
85
+ def info(*args) @tracer.push [:info, args]; end
57
86
 
58
- class MultilineRspec < LogStash::Codecs::Multiline
59
- def internal_buffer
60
- @buffer
87
+ def info?() true; end
88
+ def debug?() true; end
89
+ def warn?() true; end
90
+ def error?() true; end
61
91
  end
62
- def buffer_size
63
- @buffer.size
64
- end
65
- end
66
-
67
- class TracerBase
68
- def initialize() @tracer = []; end
69
92
 
70
- def trace_for(symbol)
71
- params = @tracer.assoc(symbol)
72
- params.nil? ? false : params.last
93
+ class AutoFlushTracer < TracerBase
94
+ def auto_flush() @tracer.push [:auto_flush, true]; end
73
95
  end
74
96
 
75
- def clear()
76
- @tracer.clear()
97
+ class IdentityMapCodecTracer < TracerBase
98
+ def clone() self.class.new; end
99
+ def decode(data) @tracer.push [:decode, data]; end
100
+ def encode(event) @tracer.push [:encode, event]; end
101
+ def flush(&block) @tracer.push [:flush, block.call]; end
102
+ def close() @tracer.push [:close, true]; end
103
+ def logger() @logger ||= MultilineLogTracer.new; end
77
104
  end
78
105
  end
79
106
 
80
- class MultilineLogTracer < TracerBase
81
- def warn(*args) @tracer.push [:warn, args]; end
82
- def error(*args) @tracer.push [:error, args]; end
83
- def debug(*args) @tracer.push [:debug, args]; end
84
- def info(*args) @tracer.push [:info, args]; end
85
-
86
- def info?() true; end
87
- def debug?() true; end
88
- def warn?() true; end
89
- def error?() true; end
90
- end
91
-
92
- class AutoFlushTracer < TracerBase
93
- def auto_flush() @tracer.push [:auto_flush, true]; end
94
- end
95
-
96
- class IdentityMapCodecTracer < TracerBase
97
- def clone() self.class.new; end
98
- def decode(data) @tracer.push [:decode, data]; end
99
- def encode(event) @tracer.push [:encode, event]; end
100
- def flush(&block) @tracer.push [:flush, block.call]; end
101
- def close() @tracer.push [:close, true]; end
102
- def logger() @logger ||= MultilineLogTracer.new; end
103
- end
104
-
105
107
  RSpec::Matchers.define(:have_an_empty_buffer) do
106
108
  match do |actual|
107
109
  actual.buffer_size.zero?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-codec-multiline
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-22 00:00:00.000000000 Z
11
+ date: 2015-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core