Skip to content
This repository
Browse code

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...
commit 37385ddb5b992769a0992ce26576b1992bee3bba 1 parent 5c85095
Prem Sichanugrist authored September 03, 2011
20  gemfiles/rails2.gemfile
@@ -2,19 +2,19 @@
2 2
 
3 3
 source "http://rubygems.org"
4 4
 
5  
-gem "sqlite3", "~>1.3.4"
6  
-gem "rails", "~> 2.3.12"
7 5
 gem "activerecord", :require=>"active_record"
  6
+gem "appraisal"
  7
+gem "aws-s3", :require=>"aws/s3"
  8
+gem "bundler"
8 9
 gem "cocaine", "~>0.2"
9  
-gem "rake"
10  
-gem "sprockets", "~> 2.0.0.beta.13", :require=>false
11  
-gem "shoulda"
12  
-gem "mime-types"
  10
+gem "fog"
13 11
 gem "jruby-openssl", :platform=>:jruby
  12
+gem "mime-types"
14 13
 gem "mocha"
15  
-gem "bundler"
16  
-gem "fog"
17  
-gem "appraisal"
18  
-gem "aws-s3", :require=>"aws/s3"
  14
+gem "rake"
19 15
 gem "rdoc", :require=>false
  16
+gem "shoulda"
  17
+gem "sqlite3", "~>1.3.4"
  18
+gem "sprockets", "~> 2.0.0.beta.13", :require=>false
  19
+gem "rails", "~> 2.3.12"
20 20
 
20  gemfiles/rails3.gemfile
@@ -2,19 +2,19 @@
2 2
 
3 3
 source "http://rubygems.org"
4 4
 
5  
-gem "sqlite3", "~>1.3.4"
6  
-gem "rails", "~> 3.0.9"
7 5
 gem "activerecord", :require=>"active_record"
  6
+gem "appraisal"
  7
+gem "aws-s3", :require=>"aws/s3"
  8
+gem "bundler"
8 9
 gem "cocaine", "~>0.2"
9  
-gem "rake"
10  
-gem "sprockets", "~> 2.0.0.beta.13", :require=>false
11  
-gem "shoulda"
12  
-gem "mime-types"
  10
+gem "fog"
13 11
 gem "jruby-openssl", :platform=>:jruby
  12
+gem "mime-types"
14 13
 gem "mocha"
15  
-gem "bundler"
16  
-gem "fog"
17  
-gem "appraisal"
18  
-gem "aws-s3", :require=>"aws/s3"
  14
+gem "rake"
19 15
 gem "rdoc", :require=>false
  16
+gem "shoulda"
  17
+gem "sqlite3", "~>1.3.4"
  18
+gem "sprockets", "~> 2.0.0.beta.13", :require=>false
  19
+gem "rails", "~> 3.0.9"
20 20
 
20  gemfiles/rails3_1.gemfile
@@ -2,19 +2,19 @@
2 2
 
3 3
 source "http://rubygems.org"
4 4
 
5  
-gem "sqlite3", "~>1.3.4"
6  
-gem "rails", "~> 3.1.0.rc5"
7 5
 gem "activerecord", :require=>"active_record"
  6
+gem "appraisal"
  7
+gem "aws-s3", :require=>"aws/s3"
  8
+gem "bundler"
8 9
 gem "cocaine", "~>0.2"
9  
-gem "rake"
10  
-gem "sprockets", "~> 2.0.0.beta.13", :require=>false
11  
-gem "shoulda"
12  
-gem "mime-types"
  10
+gem "fog"
13 11
 gem "jruby-openssl", :platform=>:jruby
  12
+gem "mime-types"
14 13
 gem "mocha"
15  
-gem "bundler"
16  
-gem "fog"
17  
-gem "appraisal"
18  
-gem "aws-s3", :require=>"aws/s3"
  14
+gem "rake"
19 15
 gem "rdoc", :require=>false
  16
+gem "shoulda"
  17
+gem "sqlite3", "~>1.3.4"
  18
+gem "sprockets", "~> 2.0.0.beta.13", :require=>false
  19
+gem "rails", "~> 3.1.0.rc5"
20 20
 
2  lib/paperclip.rb
@@ -142,7 +142,7 @@ def each_instance_with_attachment(klass, name)
142 142
       end
143 143
     end
144 144
 
145  
-    # Log a paperclip-specific line. Uses ActiveRecord::Base.logger
  145
+    # Log a paperclip-specific line. This will logs to STDOUT
146 146
     # by default. Set Paperclip.options[:log] to false to turn off.
147 147
     def log message
148 148
       logger.info("[paperclip] #{message}") if logging?
2  lib/paperclip/railtie.rb
@@ -19,6 +19,8 @@ class Railtie
19 19
     def self.insert
20 20
       ActiveRecord::Base.send(:include, Paperclip::Glue)
21 21
       File.send(:include, Paperclip::Upfile)
  22
+
  23
+      Paperclip.options[:logger] = defined?(ActiveRecord) ? ActiveRecord::Base.logger : Rails.logger
22 24
     end
23 25
   end
24 26
 end

0 notes on commit 37385dd

Please sign in to comment.
Something went wrong with that request. Please try again.