Class: EventHub::MultiLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/eventhub/multi_logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(*targets) ⇒ MultiLogger

Returns a new instance of MultiLogger.



18
19
20
# File 'lib/eventhub/multi_logger.rb', line 18

def initialize(*targets)
    @targets = targets
end

Instance Method Details

#save_detailed_error(feedback, message = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/eventhub/multi_logger.rb', line 22

def save_detailed_error(feedback,message=nil)
  time = Time.now
  stamp = "#{time.strftime("%Y%m%d_%H%M%S")}_#{"%03d" % (time.usec/1000)}"
  filename = "#{stamp}.log"

  FileUtils.makedirs("exceptions")

  File.open("exceptions/#{filename}","w") do |output|
    output.write("#{feedback}\n\n")
    output.write("Exception: #{feedback.class.to_s}\n\n")
    output.write("Call Stack:\n")
    feedback.backtrace.each do |line|
      output.write("#{line}\n")
    end
  end

  # save message if provided
  if message
   File.open("exceptions/#{stamp}.msg.raw","wb") do |output|
    output.write(message)
   end
  end  

  return stamp
end