Permalink
Browse files

Set the logger to be `AR::Base.logger` or `Rails.logger` when the gem…

… is included to Rails

However, this will make sure that you can always change it to something else afterward.

There's currently no test for this, but after I've tried this with the `integration_test` branch, I can confirm that logs are written to `log/test.log` as it should.

Closes #581
  • Loading branch information...
1 parent 5c85095 commit 37385ddb5b992769a0992ce26576b1992bee3bba @sikachu sikachu committed Sep 3, 2011
Showing with 33 additions and 31 deletions.
  1. +10 −10 gemfiles/rails2.gemfile
  2. +10 −10 gemfiles/rails3.gemfile
  3. +10 −10 gemfiles/rails3_1.gemfile
  4. +1 −1 lib/paperclip.rb
  5. +2 −0 lib/paperclip/railtie.rb
@@ -2,19 +2,19 @@
source "http://rubygems.org"
-gem "sqlite3", "~>1.3.4"
-gem "rails", "~> 2.3.12"
gem "activerecord", :require=>"active_record"
+gem "appraisal"
+gem "aws-s3", :require=>"aws/s3"
+gem "bundler"
gem "cocaine", "~>0.2"
-gem "rake"
-gem "sprockets", "~> 2.0.0.beta.13", :require=>false
-gem "shoulda"
-gem "mime-types"
+gem "fog"
gem "jruby-openssl", :platform=>:jruby
+gem "mime-types"
gem "mocha"
-gem "bundler"
-gem "fog"
-gem "appraisal"
-gem "aws-s3", :require=>"aws/s3"
+gem "rake"
gem "rdoc", :require=>false
+gem "shoulda"
+gem "sqlite3", "~>1.3.4"
+gem "sprockets", "~> 2.0.0.beta.13", :require=>false
+gem "rails", "~> 2.3.12"
@@ -2,19 +2,19 @@
source "http://rubygems.org"
-gem "sqlite3", "~>1.3.4"
-gem "rails", "~> 3.0.9"
gem "activerecord", :require=>"active_record"
+gem "appraisal"
+gem "aws-s3", :require=>"aws/s3"
+gem "bundler"
gem "cocaine", "~>0.2"
-gem "rake"
-gem "sprockets", "~> 2.0.0.beta.13", :require=>false
-gem "shoulda"
-gem "mime-types"
+gem "fog"
gem "jruby-openssl", :platform=>:jruby
+gem "mime-types"
gem "mocha"
-gem "bundler"
-gem "fog"
-gem "appraisal"
-gem "aws-s3", :require=>"aws/s3"
+gem "rake"
gem "rdoc", :require=>false
+gem "shoulda"
+gem "sqlite3", "~>1.3.4"
+gem "sprockets", "~> 2.0.0.beta.13", :require=>false
+gem "rails", "~> 3.0.9"
@@ -2,19 +2,19 @@
source "http://rubygems.org"
-gem "sqlite3", "~>1.3.4"
-gem "rails", "~> 3.1.0.rc5"
gem "activerecord", :require=>"active_record"
+gem "appraisal"
+gem "aws-s3", :require=>"aws/s3"
+gem "bundler"
gem "cocaine", "~>0.2"
-gem "rake"
-gem "sprockets", "~> 2.0.0.beta.13", :require=>false
-gem "shoulda"
-gem "mime-types"
+gem "fog"
gem "jruby-openssl", :platform=>:jruby
+gem "mime-types"
gem "mocha"
-gem "bundler"
-gem "fog"
-gem "appraisal"
-gem "aws-s3", :require=>"aws/s3"
+gem "rake"
gem "rdoc", :require=>false
+gem "shoulda"
+gem "sqlite3", "~>1.3.4"
+gem "sprockets", "~> 2.0.0.beta.13", :require=>false
+gem "rails", "~> 3.1.0.rc5"
View
@@ -142,7 +142,7 @@ def each_instance_with_attachment(klass, name)
end
end
- # Log a paperclip-specific line. Uses ActiveRecord::Base.logger
+ # Log a paperclip-specific line. This will logs to STDOUT
# by default. Set Paperclip.options[:log] to false to turn off.
def log message
logger.info("[paperclip] #{message}") if logging?
@@ -19,6 +19,8 @@ class Railtie
def self.insert
ActiveRecord::Base.send(:include, Paperclip::Glue)
File.send(:include, Paperclip::Upfile)
+
+ Paperclip.options[:logger] = defined?(ActiveRecord) ? ActiveRecord::Base.logger : Rails.logger
end
end
end

0 comments on commit 37385dd

Please sign in to comment.