Sha256: 2a9c32b51a1f05be12924dd1d8a82248ea2c279553719b9a363ea305fc18c0ff

Contents?: true

Size: 730 Bytes

Versions: 2

Compression:

Stored size: 730 Bytes

Contents

module Failsafe
  module Backends

    # File failure backend. Writes exception backtraces to a logfile.
    class File < Base
      def self.log_file_path=(log_file_path)
        @logger = nil
        @log_file_path = log_file_path
      end

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

      def self.configure
        yield(self)
      end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
failsafe-0.2.1 lib/failsafe/backends/file.rb
failsafe-0.2.0 lib/failsafe/backends/file.rb