Class: Logging::Appenders::Email
- Inherits:
-
Logging::Appender
- Object
- Logging::Appender
- Logging::Appenders::Email
- Includes:
- Buffering
- Defined in:
- lib/logging/appenders/email.rb
Constant Summary
Constants included from Buffering
Buffering::DEFAULT_BUFFER_SIZE
Instance Attribute Summary collapse
-
#acct ⇒ Object
readonly
Returns the value of attribute acct.
-
#authtype ⇒ Object
readonly
Returns the value of attribute authtype.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Attributes included from Buffering
#auto_flushing, #buffer, #flush_period
Attributes inherited from Logging::Appender
Instance Method Summary collapse
-
#initialize(name, opts = {}) ⇒ Email
constructor
TODO: make the from/to fields modifiable possibly the subject, too.
Methods included from Buffering
#close, #flush, #immediate_at=, #reopen
Methods inherited from Logging::Appender
#<<, #append, #close, #closed?, #flush, #inspect, #reopen
Constructor Details
#initialize(name, opts = {}) ⇒ Email
TODO: make the from/to fields modifiable
possibly the subject, too
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/logging/appenders/email.rb', line 20 def initialize( name, opts = {} ) super(name, opts) af = opts.getopt(:buffsize) || opts.getopt(:buffer_size) || 100 configure_buffering({:auto_flushing => af}.merge(opts)) # get the SMTP parameters @from = opts.getopt(:from) raise ArgumentError, 'Must specify from address' if @from.nil? @to = opts.getopt(:to, '').split(',') raise ArgumentError, 'Must specify recipients' if @to.empty? @server = opts.getopt :server, 'localhost' @port = opts.getopt :port, 25, :as => Integer @domain = opts.getopt(:domain, ENV['HOSTNAME']) || 'localhost.localdomain' @acct = opts.getopt :acct @passwd = opts.getopt :passwd @authtype = opts.getopt :authtype, :cram_md5, :as => Symbol @subject = opts.getopt :subject, "Message of #{$0}" @params = [@server, @port, @domain, @acct, @passwd, @authtype] end |
Instance Attribute Details
#acct ⇒ Object (readonly)
Returns the value of attribute acct.
15 16 17 |
# File 'lib/logging/appenders/email.rb', line 15 def acct @acct end |
#authtype ⇒ Object (readonly)
Returns the value of attribute authtype.
15 16 17 |
# File 'lib/logging/appenders/email.rb', line 15 def authtype @authtype end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
15 16 17 |
# File 'lib/logging/appenders/email.rb', line 15 def domain @domain end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
15 16 17 |
# File 'lib/logging/appenders/email.rb', line 15 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
15 16 17 |
# File 'lib/logging/appenders/email.rb', line 15 def server @server end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
15 16 17 |
# File 'lib/logging/appenders/email.rb', line 15 def subject @subject end |