Permalink
Browse files

Fixed that BufferedLogger should create its own directory if one does…

…nt already exist (closes #11285) [lotswholetime]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9013 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent d5a4d5a commit 13ab55f7371a2d2f0311be97bb5ed6c8378725f7 @dhh dhh committed Mar 13, 2008
@@ -1,5 +1,7 @@
*SVN*
+* Fixed that BufferedLogger should create its own directory if one doesn't already exist #11285 [lotswholetime]
+
* 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]
* Removing unneeded #change_time_zone method from Time, DateTime and TimeWithZone [Geoff Buesing]
@@ -47,6 +47,7 @@ def initialize(log, level = DEBUG)
@log = open(log, (File::WRONLY | File::APPEND))
@log.sync = true
else
+ FileUtils.mkdir_p(File.dirname(log))
@log = open(log, (File::WRONLY | File::APPEND | File::CREAT))
@log.sync = true
@log.write("# Logfile created on %s" % [Time.now.to_s])
@@ -104,4 +104,14 @@ def test_should_auto_flush_every_n_messages
@logger.info 'there it is.'
assert !@output.string.empty?, @output.string
end
+
+ def test_should_create_the_log_directory_if_it_doesnt_exist
+ tmp_directory = File.join(File.dirname(__FILE__), "tmp")
+ log_file = File.join(tmp_directory, "development.log")
+ assert !File.exist?(tmp_directory)
+ @logger = ActiveSupport::BufferedLogger.new(log_file)
+ assert File.exist?(tmp_directory)
+ ensure
+ FileUtils.rm_rf(tmp_directory)
+ end
end

0 comments on commit 13ab55f

Please sign in to comment.