mirror of
https://github.com/elastic/logstash.git
synced 2025-04-25 07:07:54 -04:00
- fix failing tests caused by scoping problems and instance_eval
This commit is contained in:
parent
6994d1dccf
commit
3b11b904a1
1 changed files with 14 additions and 9 deletions
|
@ -93,17 +93,22 @@ class LogStash::Outputs::Email < LogStash::Outputs::Base
|
||||||
public
|
public
|
||||||
def register
|
def register
|
||||||
require "mail"
|
require "mail"
|
||||||
|
|
||||||
|
# Mail uses instance_eval which changes the scope of self so @options is
|
||||||
|
# inaccessible from inside 'Mail.defaults'. So set a local variable instead.
|
||||||
|
options = @options
|
||||||
|
|
||||||
if @via == "smtp"
|
if @via == "smtp"
|
||||||
Mail.defaults do
|
Mail.defaults do
|
||||||
delivery_method :smtp, {
|
delivery_method :smtp, {
|
||||||
:address => @options.fetch("smtpIporHost", "localhost"),
|
:address => options.fetch("smtpIporHost", "localhost"),
|
||||||
:port => @options.fetch("port", 25),
|
:port => options.fetch("port", 25),
|
||||||
:domain => @options.fetch("domain", "localhost"),
|
:domain => options.fetch("domain", "localhost"),
|
||||||
:user_name => @options.fetch("userName", nil),
|
:user_name => options.fetch("userName", nil),
|
||||||
:password => @options.fetch("password", nil),
|
:password => options.fetch("password", nil),
|
||||||
:authentication => @options.fetch("authenticationType", nil),
|
:authentication => options.fetch("authenticationType", nil),
|
||||||
:enable_starttls_auto => @options.fetch("starttls", false),
|
:enable_starttls_auto => options.fetch("starttls", false),
|
||||||
:debug => @options.fetch("debug", false)
|
:debug => options.fetch("debug", false)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
elsif @via == 'sendmail'
|
elsif @via == 'sendmail'
|
||||||
|
@ -112,7 +117,7 @@ class LogStash::Outputs::Email < LogStash::Outputs::Base
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Mail.defaults do
|
Mail.defaults do
|
||||||
delivery_method :@via, @options
|
delivery_method :@via, options
|
||||||
end
|
end
|
||||||
end # @via tests
|
end # @via tests
|
||||||
@logger.debug("Email Output Registered!", :config => @config)
|
@logger.debug("Email Output Registered!", :config => @config)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue