Sha256: e1c255b5111718c32e9a7a93c2de59c0381f76338b9e9788bed5598462671ece

Contents?: true

Size: 662 Bytes

Versions: 2

Compression:

Stored size: 662 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("#{e.class} #{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.6.1 lib/ab_admin/utils/logger.rb
ab_admin-0.6.0 lib/ab_admin/utils/logger.rb