Class: Log4r::EmailOutputter

Inherits:
Outputter
  • Object
show all
Defined in:
lib/log4r/outputter/emailoutputter.rb

Instance Attribute Summary collapse

Attributes inherited from Outputter

#formatter, #level, #name

Instance Method Summary collapse

Methods inherited from Outputter

[], []=, each, each_outputter, #only_at, stderr, stdout

Constructor Details

#initialize(_name, hash = {}) ⇒ EmailOutputter

Returns a new instance of EmailOutputter.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/log4r/outputter/emailoutputter.rb', line 12

def initialize(_name, hash={})
  super(_name, hash)
  validate(hash)
  @buff = []
  begin 
	Logger.log_internal {
	  "EmailOutputter '#{@name}' running SMTP client on #{@server}:#{@port}"
	}
  rescue Exception => e
	Logger.log_internal(-2) {
	  "EmailOutputter '#{@name}' failed to start SMTP client!"
	}
	Logger.log_internal {e}
	self.level = OFF
	raise e
  end
end

Instance Attribute Details

#acctObject (readonly)

Returns the value of attribute acct.



10
11
12
# File 'lib/log4r/outputter/emailoutputter.rb', line 10

def acct
  @acct
end

#authtypeObject (readonly)

Returns the value of attribute authtype.



10
11
12
# File 'lib/log4r/outputter/emailoutputter.rb', line 10

def authtype
  @authtype
end

#domainObject (readonly)

Returns the value of attribute domain.



10
11
12
# File 'lib/log4r/outputter/emailoutputter.rb', line 10

def domain
  @domain
end

#portObject (readonly)

Returns the value of attribute port.



10
11
12
# File 'lib/log4r/outputter/emailoutputter.rb', line 10

def port
  @port
end

#serverObject (readonly)

Returns the value of attribute server.



10
11
12
# File 'lib/log4r/outputter/emailoutputter.rb', line 10

def server
  @server
end

#subjectObject (readonly)

Returns the value of attribute subject.



10
11
12
# File 'lib/log4r/outputter/emailoutputter.rb', line 10

def subject
  @subject
end

#tlsObject (readonly)

Returns the value of attribute tls.



10
11
12
# File 'lib/log4r/outputter/emailoutputter.rb', line 10

def tls
  @tls
end

Instance Method Details

#flushObject

send out an email with the current buffer



31
32
33
34
# File 'lib/log4r/outputter/emailoutputter.rb', line 31

def flush
  synch { send_mail }
  Logger.log_internal {"Flushed EmailOutputter '#{@name}'"}
end