Class: Safely::Strategy::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/safely/strategy/log.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.flushObject

Flush logger



11
12
13
# File 'lib/safely/strategy/log.rb', line 11

def flush
  @flush
end

.loggerObject

Logger to use



8
9
10
# File 'lib/safely/strategy/log.rb', line 8

def logger
  @logger
end

Class Method Details

.load!Object



13
14
15
# File 'lib/safely/strategy/log.rb', line 13

def load!
  @flush ||= false
end

.report!(exception) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/safely/strategy/log.rb', line 17

def report!( exception )
  return if self.logger.nil?

  self.logger.error("[SAFELY] Type: #{exception.class.name}")
  self.logger.error("[SAFELY] Message: #{exception.message}")
  self.logger.error("[SAFELY] Backtrace: #{exception.backtrace.join("\n  ")}")

  self.logger.flush if self.logger.respond_to?(:flush) && self.flush
end