Sha256: ecdda83903cd8179f72ed2d1d7f83959c1ea8e4c751b426b8a6f09ec223a6ef4

Contents?: true

Size: 863 Bytes

Versions: 4

Compression:

Stored size: 863 Bytes

Contents

module ActionController::OutputLogging
  def with_output_logging
    around_filter ActionController::OutputLogging
  end

  def self.filter(controller, &block)
    yield
    do_output_logging controller, nil
  rescue
    do_output_logging controller, $!
  end
    
  def self.do_output_logging(controller, exception)
    msg = []
      
    msg << "#{Time.now}: #{controller.request.query_string}"
    msg << (controller.params.to_a.sort_by(&:first).map { |k,v| "  #{k}: #{v.inspect}"}).join("\n")
    msg << "Caught exception #{exception.inspect}" if exception
    msg << controller.response.body
    msg = msg.join("\n" + "-" * 80 + "\n") + "\n" + "=" * 80

    logger.warn msg
  end
    
  def self.logger
    @logger ||= ActiveSupport::BufferedLogger.new "#{RAILS_ROOT}/log/output.log"
  end
end

ActionController::Base.extend ActionController::OutputLogging

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vex-0.6.2 lib/vex/action_controller/output_logging.rb
vex-0.4.4 lib/vex/action_controller/output_logging.rb
vex-0.4.2 lib/vex/action_controller/output_logging.rb
vex-0.3.3 lib/vex/action_controller/output_logging.rb