public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Fixed that BufferedLogger should create its own directory if one doesnt 
already exist (closes #11285) [lotswholetime]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9013 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
dhh (author)
Wed Mar 12 18:54:34 -0700 2008
commit  13ab55f7371a2d2f0311be97bb5ed6c8378725f7
tree    7b92ba2bf9362ba6d8d2dbb6b2171b62806c07fa
parent  d5a4d5abb41c50f96b554374b937ffe49d472d7f
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Fixed that BufferedLogger should create its own directory if one doesn't already exist #11285 [lotswholetime]
0
+
0
 * Fix Numeric time tests broken by DST change by anchoring them to fixed times instead of Time.now. Anchor TimeZone#now DST test to time specified with Time.at instead of Time.local to work around platform differences with Time.local and DST representation [Geoff Buesing]
0
 
0
 * Removing unneeded #change_time_zone method from Time, DateTime and TimeWithZone [Geoff Buesing]
...
47
48
49
 
50
51
52
...
47
48
49
50
51
52
53
0
@@ -47,6 +47,7 @@ module ActiveSupport
0
         @log = open(log, (File::WRONLY | File::APPEND))
0
         @log.sync = true
0
       else
0
+ FileUtils.mkdir_p(File.dirname(log))
0
         @log = open(log, (File::WRONLY | File::APPEND | File::CREAT))
0
         @log.sync = true
0
         @log.write("# Logfile created on %s" % [Time.now.to_s])
...
104
105
106
 
 
 
 
 
 
 
 
 
 
107
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
0
@@ -104,4 +104,14 @@ class BufferedLoggerTest < Test::Unit::TestCase
0
     @logger.info 'there it is.'
0
     assert !@output.string.empty?, @output.string
0
   end
0
+
0
+ def test_should_create_the_log_directory_if_it_doesnt_exist
0
+ tmp_directory = File.join(File.dirname(__FILE__), "tmp")
0
+ log_file = File.join(tmp_directory, "development.log")
0
+ assert !File.exist?(tmp_directory)
0
+ @logger = ActiveSupport::BufferedLogger.new(log_file)
0
+ assert File.exist?(tmp_directory)
0
+ ensure
0
+ FileUtils.rm_rf(tmp_directory)
0
+ end
0
 end

Comments

    No one has commented yet.