Class: Mole::EMole

Inherits:
ActionMailer::Base
  • Object
show all
Defined in:
lib/mole/e_mole.rb

Instance Method Summary collapse

Instance Method Details

#dump_args(args) ⇒ Object

dumps arguments



63
64
65
66
67
68
69
70
71
72
# File 'lib/mole/e_mole.rb', line 63

def dump_args( args )
  return "N/A" unless args
  buff = []
  args.keys.sort { |a,b| a.to_s <=> b.to_s}.each do |k|  
    key   = k.to_s.rjust(20)
    value = args[k].to_s.rjust(97,".")
    buff << "#{key} :  #{value}" 
  end
  buff.join( "\r" )
end

#dump_stack(boom) ⇒ Object

dumps partial stack



58
59
60
# File 'lib/mole/e_mole.rb', line 58

def dump_stack( boom )      
  buff = boom.backtrace[0...3].join( "\r" )
end

#exception_alerts(context, user_id, options = {}) ⇒ Object

send out mole exception alerts



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/mole/e_mole.rb', line 44

def exception_alerts( context, user_id, options={} )
  Mole.logger.debug "Sending perf email from #{::Mole.emole_from} -- to #{::Mole.emole_recipients}"                  
  subject     "[EXCEPTION] #{@host} -- #{Mole.application} -- #{user_id}"        
  body        :application  => Mole.application,
              :host_name    => @host,
              :context      => context.class.name,
              :feature      => options[:feature],
              :boom         => options[:boom],  
              :trace        => dump_stack( options[:boom] ),
              :args         => dump_args( options )                  
end

#feature_alerts(context, user_id, options = {}) ⇒ Object

send out feature alerts



19
20
21
22
23
24
25
26
27
# File 'lib/mole/e_mole.rb', line 19

def feature_alerts( context, user_id, options={} )
  Mole.logger.debug "Sending feature email from #{::Mole.emole_from} -- to #{::Mole.emole_recipients}"                  
  subject     "[FEATURE] #{options[:feature]} -- #{@host} -- #{Mole.application} -- #{user_id}"        
  body        :application  => Mole.application,
              :host_name    => @host,
              :context      => context.class.name,
              :feature      => options[:feature],
              :args         => dump_args( options )
end

#perf_alerts(context, user_id, options = {}) ⇒ Object

send out mole performance alert



31
32
33
34
35
36
37
38
39
40
# File 'lib/mole/e_mole.rb', line 31

def perf_alerts( context, user_id, options={} )                                                                      
  Mole.logger.debug "Sending perf email from #{::Mole.emole_from} -- to #{::Mole.emole_recipients}"                  
  subject     "[PERF] #{@host} -- #{Mole.application} -- #{user_id}"        
  body        :application  => ::Mole.application,       
              :host_name    => @host,      
              :context      => context.class.name,
              :feature      => options[:feature],                          
              :elapsed_time => options[:elapsed_time] ,
              :args         => dump_args( options )
end

#setupObject

:nodoc:



7
8
9
10
11
# File 'lib/mole/e_mole.rb', line 7

def setup #:nodoc:
  recipients  ::Mole.emole_recipients
  from        ::Mole.emole_from             
  @host = `hostname`      
end