Class: Failsafe::Backends::File

Inherits:
Base
  • Object
show all
Defined in:
lib/failsafe/backends/file.rb

Overview

File failure backend. Writes exception backtraces to a logfile.

Instance Attribute Summary

Attributes inherited from Base

#exception

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Failsafe::Backends::Base

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



15
16
17
# File 'lib/failsafe/backends/file.rb', line 15

def self.configure
  yield(self)
end

.log_file_pathObject



11
12
13
# File 'lib/failsafe/backends/file.rb', line 11

def self.log_file_path
  @log_file_path || ::File.join(Rails.root, 'log', 'failsafe_errors.log')
end

.log_file_path=(log_file_path) ⇒ Object



6
7
8
9
# File 'lib/failsafe/backends/file.rb', line 6

def self.log_file_path=(log_file_path)
  @logger = nil
  @log_file_path = log_file_path
end

.loggerObject



19
20
21
# File 'lib/failsafe/backends/file.rb', line 19

def self.logger
  @logger ||= ::Logger.new(log_file_path).tap { |l| l.formatter = Logger::Formatter.new }
end

Instance Method Details

#saveObject



23
24
25
26
27
28
# File 'lib/failsafe/backends/file.rb', line 23

def save
  msg = []
  msg << exception.message
  msg << exception.backtrace.join("\n")
  self.class.logger.error(msg.join)
end