Sha256: a4edc53d09d269586b277fa116b376a0ec6c9e9decaba3f05d580015fdeff0fc

Contents?: true

Size: 651 Bytes

Versions: 2

Compression:

Stored size: 651 Bytes

Contents

module AbAdmin
  module Utils
    module Logger

      class ExtendedLogger < ::Logger
        def exception(e, options={})
          message = "#{e.message} #{"DATA:#{options[:data].inspect}" if options && options[:data]}"
          backtrace = e.backtrace.map { |l| "#{' ' * 2}#{l}" }.join("\n")
          error("#{message}\n#{backtrace}\n\n")
        end

        def reopen
          @logdev = LogDevice.new(@logdev.filename)
        end
      end

      def self.for_file(filename)
        logger = ExtendedLogger.new(Rails.root.join('log', filename))
        logger.formatter = ::Logger::Formatter.new
        logger
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ab_admin-0.5.0 lib/ab_admin/utils/logger.rb
ab_admin-0.4.0 lib/ab_admin/utils/logger.rb