logstash-output-email 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: f0a68fd022674e4fd1d643538cdd2b6382234c0d
4
- data.tar.gz: 5b9b5eb6e82ba496f6cc53a8861741f667a20ef7
3
+ metadata.gz: 9113b32924f9aa3aaf948a2def10f4de02e304a6
4
+ data.tar.gz: 685b26596c503699d5ab855720619cff6cb26075
5
5
  SHA512:
6
- metadata.gz: 0932698618bfbc0d704a91af0bfaafa51aca69a554a482194b024b0f2f715dad95d536174eb990be69fafabc458e4429a3df67aef04aceb8531faf25e6fddf3a
7
- data.tar.gz: 97120bbd6b5534c22c32fe8e62375ca03f4d67f3c3c45473fc230d74c90551b7589da86e14a1d77c35728554974ac168da3c67131f4e9cb9911fa9c405d982eb
6
+ metadata.gz: e29a2e50322bd6b9eef87bc9f786834b0f4f58ff4f1a2746c14282915e8635fc2ce948bb48f03b188d07d014f5cc3a238503f6b3616f05460c59f00d4c901dad
7
+ data.tar.gz: c9ac9d5fe22bbf02b1a57e2348b5d26b19fd6eb5709d7509ffb61fdc5958a314c74405784f136f17c623ba5103b39fd3461e343f0cd3eb77e57a36cc1ea61bf5
data/CHANGELOG.md CHANGED
@@ -0,0 +1,5 @@
1
+ # 1.1.0
2
+ - Make the delivery method more reliable to failure by catching and
3
+ logging exceptions when happen, like this LS is not going to break
4
+ if something wrong happen, but is going to log it. Fixes #26 and #7
5
+ - Randomize port in specs so they can run in parallel.
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # Logstash Plugin
2
2
 
3
- This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
3
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
4
 
5
5
  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.
6
6
 
7
7
  ## Documentation
8
8
 
9
- Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
9
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
10
10
 
11
11
  - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
- - For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
12
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
13
13
 
14
14
  ## Need Help?
15
15
 
@@ -83,4 +83,4 @@ Programming is not a required skill. Whatever you've seen about open source and
83
83
 
84
84
  It is more important to the community that you are able to contribute.
85
85
 
86
- For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
86
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -247,7 +247,12 @@ class LogStash::Outputs::Email < LogStash::Outputs::Base
247
247
  mail.add_file(fileLocation)
248
248
  end # end @attachments.each
249
249
  @logger.debug? and @logger.debug("Sending mail with these values : ", :from => mail.from, :to => mail.to, :cc => mail.cc, :subject => mail.subject)
250
- mail.deliver!
250
+ begin
251
+ mail.deliver!
252
+ rescue StandardError => e
253
+ @logger.error("Something happen while delivering an email", :exception => e)
254
+ @logger.debug? && @logger.debug("Processed event: ", :event => event)
255
+ end
251
256
  end # end if successful
252
257
  end # def receive
253
258
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-email'
4
- s.version = '1.0.0'
4
+ s.version = '1.1.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Send email when an output is received."
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"
@@ -5,10 +5,10 @@ require "message_observers"
5
5
 
6
6
  describe "outputs/email" do
7
7
 
8
- port = 2525
9
- let (:rumbster) { Rumbster.new(port) }
8
+ let (:port) { rand(1024..65535) }
9
+ let (:rumbster) { Rumbster.new(port) }
10
10
  let (:message_observer) { MailMessageObserver.new }
11
- plugin = LogStash::Plugin.lookup("output", "email")
11
+ let(:plugin) { LogStash::Plugin.lookup("output", "email") }
12
12
 
13
13
 
14
14
  before :each do
@@ -21,75 +21,91 @@ describe "outputs/email" do
21
21
  sleep 0.01 until rumbster.stopped?
22
22
  end
23
23
 
24
- describe "use a list of email as mail.to (LOGSTASH-827)" do
24
+ describe "send email" do
25
25
 
26
- it "supports list of emails in to field" do
27
- subject = plugin.new("to" => ["email1@host, email2@host"],
28
- "match" => ["mymatch", "dummy_match,ok"],
29
- "options" => ["port", port])
30
- subject.register
31
- subject.receive(LogStash::Event.new("message" => "hello", "dummy_match" => "ok"))
32
- expect(message_observer.messages.size).to eq(1)
33
- expect(message_observer.messages[0].to).to eq(["email1@host", "email2@host"])
26
+ context "use a list of email as mail.to (LOGSTASH-827)" do
27
+
28
+ it "supports list of emails in to field" do
29
+ subject = plugin.new("to" => ["email1@host, email2@host"],
30
+ "match" => ["mymatch", "dummy_match,ok"],
31
+ "options" => ["port", port])
32
+ subject.register
33
+ subject.receive(LogStash::Event.new("message" => "hello", "dummy_match" => "ok"))
34
+ expect(message_observer.messages.size).to eq(1)
35
+ expect(message_observer.messages[0].to).to eq(["email1@host", "email2@host"])
36
+ end
37
+
38
+ it "multiple *to* addresses in a field" do
39
+ subject = plugin.new("to" => "%{to_addr}",
40
+ "match" => ["mymatch", "dummy_match,ok"],
41
+ "options" => ["port", port])
42
+ subject.register
43
+ subject.receive(LogStash::Event.new("message" => "hello",
44
+ "dummy_match" => "ok",
45
+ "to_addr" => ["email1@host", "email2@host"]))
46
+ expect(message_observer.messages.size).to eq(1)
47
+ expect(message_observer.messages[0].to).to eq(["email1@host", "email2@host"])
48
+ end
34
49
  end
35
50
 
36
- it "multiple *to* addresses in a field" do
37
- subject = plugin.new("to" => "%{to_addr}",
38
- "match" => ["mymatch", "dummy_match,ok"],
39
- "options" => ["port", port])
40
- subject.register
41
- subject.receive(LogStash::Event.new("message" => "hello",
42
- "dummy_match" => "ok",
43
- "to_addr" => ["email1@host", "email2@host"]))
44
- expect(message_observer.messages.size).to eq(1)
45
- expect(message_observer.messages[0].to).to eq(["email1@host", "email2@host"])
51
+ context "multi-lined text body (LOGSTASH-841)" do
52
+ it "handles multiline messages" do
53
+ subject = plugin.new("to" => "me@host",
54
+ "subject" => "Hello World",
55
+ "body" => "Line1\\nLine2\\nLine3",
56
+ "match" => ["mymatch", "dummy_match,*"],
57
+ "options" => ["port", port])
58
+ subject.register
59
+ subject.receive(LogStash::Event.new("message" => "hello", "dummy_match" => "ok"))
60
+ expect(message_observer.messages.size).to eq(1)
61
+ expect(message_observer.messages[0].subject).to eq("Hello World")
62
+ expect(message_observer.messages[0].body.raw_source).to eq("Line1\r\nLine2\r\nLine3\r\n")
63
+ end
46
64
  end
47
- end
48
65
 
49
- describe "multi-lined text body (LOGSTASH-841)" do
50
- it "handles multiline messages" do
51
- subject = plugin.new("to" => "me@host",
52
- "subject" => "Hello World",
53
- "body" => "Line1\\nLine2\\nLine3",
54
- "match" => ["mymatch", "dummy_match,*"],
55
- "options" => ["port", port])
56
- subject.register
57
- subject.receive(LogStash::Event.new("message" => "hello", "dummy_match" => "ok"))
58
- expect(message_observer.messages.size).to eq(1)
59
- expect(message_observer.messages[0].subject).to eq("Hello World")
60
- expect(message_observer.messages[0].body.raw_source).to eq("Line1\r\nLine2\r\nLine3\r\n")
66
+ context "use nil authenticationType (LOGSTASH-559)" do
67
+ it "reads messages correctly" do
68
+ subject = plugin.new("to" => "me@host",
69
+ "subject" => "Hello World",
70
+ "body" => "Line1\\nLine2\\nLine3",
71
+ "match" => ["mymatch", "dummy_match,*"],
72
+ "options" => ["port", port, "authenticationType", "nil"])
73
+ subject.register
74
+ subject.receive(LogStash::Event.new("message" => "hello", "dummy_match" => "ok"))
75
+ expect(message_observer.messages.size).to eq(1)
76
+ expect(message_observer.messages[0].subject).to eq("Hello World")
77
+ expect(message_observer.messages[0].body.raw_source).to eq("Line1\r\nLine2\r\nLine3\r\n")
78
+ end
61
79
  end
62
- end
63
80
 
64
- describe "use nil authenticationType (LOGSTASH-559)" do
65
- it "reads messages correctly" do
66
- subject = plugin.new("to" => "me@host",
67
- "subject" => "Hello World",
68
- "body" => "Line1\\nLine2\\nLine3",
69
- "match" => ["mymatch", "dummy_match,*"],
70
- "options" => ["port", port, "authenticationType", "nil"])
71
- subject.register
72
- subject.receive(LogStash::Event.new("message" => "hello", "dummy_match" => "ok"))
73
- expect(message_observer.messages.size).to eq(1)
74
- expect(message_observer.messages[0].subject).to eq("Hello World")
75
- expect(message_observer.messages[0].body.raw_source).to eq("Line1\r\nLine2\r\nLine3\r\n")
81
+ context "match on source and message (LOGSTASH-826)" do
82
+ it "reads messages correctly" do
83
+ subject = plugin.new("to" => "me@host",
84
+ "subject" => "Hello World",
85
+ "body" => "Mail body",
86
+ "match" => [ "messageAndSourceMatch", "message,*hello,,and,type,*generator"],
87
+ "options" => ["port", port, "authenticationType", "nil"])
88
+ subject.register
89
+ subject.receive(LogStash::Event.new("message" => "hello world", "type" => "generator"))
90
+ expect(message_observer.messages.size).to eq(1)
91
+ expect(message_observer.messages[0].subject).to eq("Hello World")
92
+ expect(message_observer.messages[0].body.raw_source).to eq("Mail body\r\n")
93
+ end
76
94
  end
77
- end
78
95
 
79
- describe "match on source and message (LOGSTASH-826)" do
80
- it "reads messages correctly" do
81
- subject = plugin.new("to" => "me@host",
82
- "subject" => "Hello World",
83
- "body" => "Mail body",
84
- "match" => [ "messageAndSourceMatch", "message,*hello,,and,type,*generator"],
85
- "options" => ["port", port, "authenticationType", "nil"])
86
- subject.register
87
- subject.receive(LogStash::Event.new("message" => "hello world", "type" => "generator"))
88
- expect(message_observer.messages.size).to eq(1)
89
- expect(message_observer.messages[0].subject).to eq("Hello World")
90
- expect(message_observer.messages[0].body.raw_source).to eq("Mail body\r\n")
96
+ context "having no connection to the email server" do
97
+
98
+ subject { plugin.new("to" => "me@host") }
99
+ let(:event) { LogStash::Event.new("message" => "hello world") }
100
+
101
+ before(:each) do
102
+ subject.register
103
+ end
104
+
105
+ it "should send without throwing an error" do
106
+ expect { subject.receive(event) }.not_to raise_error
107
+ end
91
108
  end
109
+
92
110
  end
93
111
  end
94
-
95
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-email
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
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-24 00:00:00.000000000 Z
11
+ date: 2015-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  version: '0'
133
133
  requirements: []
134
134
  rubyforge_project:
135
- rubygems_version: 2.2.2
135
+ rubygems_version: 2.4.6
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: Send email when an output is received.