logstash-core-event-java 5.0.0.alpha6.snapshot5-java → 5.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstash-core-event-java/logstash-core-event-java.jar +0 -0
- data/lib/logstash-core-event-java/logstash-core-event-java.rb +1 -1
- data/lib/logstash-core-event-java/version.rb +1 -1
- data/lib/logstash/event.rb +18 -1
- data/lib/logstash/string_interpolation.rb +2 -2
- data/spec/event_spec.rb +23 -8
- metadata +4 -6
- data/lib/com/fasterxml/jackson/core/jackson-core/2.7.1/jackson-core-2.7.1.jar +0 -0
- data/lib/com/fasterxml/jackson/core/jackson-databind/2.7.1-1/jackson-databind-2.7.1-1.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e91246ebcab4d5729e3b452816a10fe8025a7b0
|
4
|
+
data.tar.gz: 1b01a6229f0c1103d45c3b1ec1ef52f9309c4a47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8636ce4953e1ca650f13527d6e60021db69675d70c7c359659a43ee7711bbf944c5b5dca2a15fc6e7d58ebaaabd1eb274b90295c414993f5e71b6b7a0409e266
|
7
|
+
data.tar.gz: 393c31cc0c9e2abd277983d1f9a0321475f179131f5e120a55d07e4eb4c7db9c9a948cf3115411cabe7d9c21983fb5fd9fdcdb81f2bc8c189dfe8ed0e268a788
|
Binary file
|
data/lib/logstash/event.rb
CHANGED
@@ -29,9 +29,26 @@ module LogStash
|
|
29
29
|
|
30
30
|
# LogStash::SHUTDOWN is used by plugins
|
31
31
|
SHUTDOWN = ShutdownEvent.new
|
32
|
+
|
33
|
+
class Event
|
34
|
+
MSG_BRACKETS_METHOD_MISSING = "Direct event field references (i.e. event['field']) have been disabled in favor of using event get and set methods (e.g. event.get('field')). Please consult the Logstash 5.0 breaking changes documentation for more details.".freeze
|
35
|
+
MSG_BRACKETS_EQUALS_METHOD_MISSING = "Direct event field references (i.e. event['field'] = 'value') have been disabled in favor of using event get and set methods (e.g. event.set('field', 'value')). Please consult the Logstash 5.0 breaking changes documentation for more details.".freeze
|
36
|
+
RE_BRACKETS_METHOD = /^\[\]$/.freeze
|
37
|
+
RE_BRACKETS_EQUALS_METHOD = /^\[\]=$/.freeze
|
38
|
+
|
39
|
+
def method_missing(method_name, *arguments, &block)
|
40
|
+
if RE_BRACKETS_METHOD.match(method_name.to_s)
|
41
|
+
raise NoMethodError.new(MSG_BRACKETS_METHOD_MISSING)
|
42
|
+
end
|
43
|
+
if RE_BRACKETS_EQUALS_METHOD.match(method_name.to_s)
|
44
|
+
raise NoMethodError.new(MSG_BRACKETS_EQUALS_METHOD_MISSING)
|
45
|
+
end
|
46
|
+
super
|
47
|
+
end
|
48
|
+
end
|
32
49
|
end
|
33
50
|
|
34
51
|
# for backward compatibility, require "logstash/event" is used a lots of places so let's bootstrap the
|
35
52
|
# Java code loading from here.
|
36
53
|
# TODO: (colin) I think we should mass replace require "logstash/event" with require "logstash-core-event"
|
37
|
-
require "logstash-core-event"
|
54
|
+
require "logstash-core-event"
|
@@ -6,12 +6,12 @@ module LogStash
|
|
6
6
|
|
7
7
|
# clear the global compiled templates cache
|
8
8
|
def clear_cache
|
9
|
-
Java::
|
9
|
+
Java::OrgLogstash::StringInterpolation.get_instance.clear_cache;
|
10
10
|
end
|
11
11
|
|
12
12
|
# @return [Fixnum] the compiled templates cache size
|
13
13
|
def cache_size
|
14
|
-
Java::
|
14
|
+
Java::OrgLogstash::StringInterpolation.get_instance.cache_size;
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/spec/event_spec.rb
CHANGED
@@ -5,7 +5,6 @@ require "logstash/util"
|
|
5
5
|
require "logstash/event"
|
6
6
|
require "json"
|
7
7
|
require "java"
|
8
|
-
# java_import 'com.logstash.Util'
|
9
8
|
|
10
9
|
TIMESTAMP = "@timestamp"
|
11
10
|
|
@@ -36,7 +35,7 @@ describe LogStash::Event do
|
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
39
|
-
context "
|
38
|
+
context "#get" do
|
40
39
|
it "should get simple values" do
|
41
40
|
e = LogStash::Event.new({"foo" => "bar", "bar" => 1, "baz" => 1.0, TIMESTAMP => "2015-05-28T23:02:05.350Z"})
|
42
41
|
expect(e.get("foo")).to eq("bar")
|
@@ -64,7 +63,7 @@ describe LogStash::Event do
|
|
64
63
|
end
|
65
64
|
end
|
66
65
|
|
67
|
-
context "
|
66
|
+
context "#set" do
|
68
67
|
it "should set simple values" do
|
69
68
|
e = LogStash::Event.new()
|
70
69
|
expect(e.set("foo", "bar")).to eq("bar")
|
@@ -123,7 +122,7 @@ describe LogStash::Event do
|
|
123
122
|
end
|
124
123
|
|
125
124
|
it "should set XXJavaProxy Jackson crafted" do
|
126
|
-
proxy =
|
125
|
+
proxy = org.logstash.Util.getMapFixtureJackson()
|
127
126
|
# proxy is {"string": "foo", "int": 42, "float": 42.42, "array": ["bar","baz"], "hash": {"string":"quux"} }
|
128
127
|
e = LogStash::Event.new()
|
129
128
|
e.set("[proxy]", proxy)
|
@@ -136,7 +135,7 @@ describe LogStash::Event do
|
|
136
135
|
end
|
137
136
|
|
138
137
|
it "should set XXJavaProxy hand crafted" do
|
139
|
-
proxy =
|
138
|
+
proxy = org.logstash.Util.getMapFixtureHandcrafted()
|
140
139
|
# proxy is {"string": "foo", "int": 42, "float": 42.42, "array": ["bar","baz"], "hash": {"string":"quux"} }
|
141
140
|
e = LogStash::Event.new()
|
142
141
|
e.set("[proxy]", proxy)
|
@@ -159,12 +158,12 @@ describe LogStash::Event do
|
|
159
158
|
it "to_hash should inject a Ruby LogStash::Timestamp" do
|
160
159
|
e = LogStash::Event.new()
|
161
160
|
|
162
|
-
expect(e.to_java).to be_kind_of(Java::
|
163
|
-
expect(e.to_java.get_field(TIMESTAMP)).to be_kind_of(Java::
|
161
|
+
expect(e.to_java).to be_kind_of(Java::OrgLogstash::Event)
|
162
|
+
expect(e.to_java.get_field(TIMESTAMP)).to be_kind_of(Java::OrgLogstash::Timestamp)
|
164
163
|
|
165
164
|
expect(e.to_hash[TIMESTAMP]).to be_kind_of(LogStash::Timestamp)
|
166
165
|
# now make sure the original map was not touched
|
167
|
-
expect(e.to_java.get_field(TIMESTAMP)).to be_kind_of(Java::
|
166
|
+
expect(e.to_java.get_field(TIMESTAMP)).to be_kind_of(Java::OrgLogstash::Timestamp)
|
168
167
|
end
|
169
168
|
|
170
169
|
it "should set timestamp" do
|
@@ -307,4 +306,20 @@ describe LogStash::Event do
|
|
307
306
|
end
|
308
307
|
|
309
308
|
end
|
309
|
+
|
310
|
+
context "method missing exception messages" do
|
311
|
+
subject { LogStash::Event.new({"foo" => "bar"}) }
|
312
|
+
|
313
|
+
it "#[] method raises a better exception message" do
|
314
|
+
expect { subject["foo"] }.to raise_error(NoMethodError, /Direct event field references \(i\.e\. event\['field'\]\)/)
|
315
|
+
end
|
316
|
+
|
317
|
+
it "#[]= method raises a better exception message" do
|
318
|
+
expect { subject["foo"] = "baz" }.to raise_error(NoMethodError, /Direct event field references \(i\.e\. event\['field'\] = 'value'\)/)
|
319
|
+
end
|
320
|
+
|
321
|
+
it "other missing method raises normal exception message" do
|
322
|
+
expect { subject.baz() }.to raise_error(NoMethodError, /undefined method `baz' for/)
|
323
|
+
end
|
324
|
+
end
|
310
325
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-core-event-java
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.0
|
4
|
+
version: 5.0.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,9 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- lib/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0.jar
|
49
|
-
- lib/com/fasterxml/jackson/core/jackson-core/2.7.1/jackson-core-2.7.1.jar
|
50
49
|
- lib/com/fasterxml/jackson/core/jackson-core/2.7.3/jackson-core-2.7.3.jar
|
51
|
-
- lib/com/fasterxml/jackson/core/jackson-databind/2.7.1-1/jackson-databind-2.7.1-1.jar
|
52
50
|
- lib/com/fasterxml/jackson/core/jackson-databind/2.7.3/jackson-databind-2.7.3.jar
|
53
51
|
- lib/logstash-core-event-java.rb
|
54
52
|
- lib/logstash-core-event-java/logstash-core-event-java.jar
|
@@ -77,9 +75,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
75
|
version: '0'
|
78
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
77
|
requirements:
|
80
|
-
- - "
|
78
|
+
- - ">="
|
81
79
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
80
|
+
version: '0'
|
83
81
|
requirements:
|
84
82
|
- jar com.fasterxml.jackson.core:jackson-core, 2.7.3
|
85
83
|
- jar com.fasterxml.jackson.core:jackson-databind, 2.7.3
|
Binary file
|