mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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
This commit is contained in:
parent
d5a4d5abb4
commit
13ab55f737
3 changed files with 13 additions and 0 deletions
|
@ -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 @@ module ActiveSupport
|
|||
@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 @@ class BufferedLoggerTest < Test::Unit::TestCase
|
|||
@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
|
||||
|
|
Loading…
Reference in a new issue