Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Mongoid::Paperclip removes logger configuration from Paperclip #20

Open
ashmoran opened this Issue · 0 comments

1 participant

@ashmoran

The Rails project I'm currently working on has tests for Mongoid objects (RSpec model specs) that don't depend on Rails, they make a Mongoid database connection by hand and don't boot Rails. Also, we disabled Mongoid logging by default as the output isn't usually useful

Mongoid::Paperclip overrides the Paperclip.logger method to be this:

module Paperclip
  class << self
    def logger
      if Mongoid::Config.logger.present?
        Mongoid::Config.logger
      else
        Rails.logger
      end
    end
  end
end

Our tests were failing because, without a Mongoid logger, they were trying to access the Rails logger.

The original Paperclip implementation is this:

module Paperclip
  class << self
    def logger #:nodoc:
      @logger ||= options[:logger] || Logger.new(STDOUT)
    end
  end
end

I have now re-monkeypatched Paperclip and use Paperclip.logger = Logger.new(nil) to disable logging.

Is there a way Paperclip::Mongoid could retain both useful defaults for the logger and the ability to configure (override) it?

(Another potential issue I can see is an app that uses Paperclip with both ActiveRecord and Mongoid, in which case all the logs will be sent to the Mongoid logger, which would probably not make sense. I've not dug into the code to see if this could actually happen though.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.