Method: Logging::Appenders::File.assert_valid_logfile
- Defined in:
- lib/logging/appenders/file.rb
.assert_valid_logfile(fn) ⇒ Object
call-seq:
File.assert_valid_logfile( filename ) => true
Asserts that the given filename can be used as a log file by ensuring that if the file exists it is a regular file and it is writable. If the file does not exist, then the directory is checked to see if it is writable.
An ArgumentError is raised if any of these assertions fail.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/logging/appenders/file.rb', line 22 def self.assert_valid_logfile( fn ) if ::File.exist?(fn) if !::File.file?(fn) raise ArgumentError, "#{fn} is not a regular file" elsif !::File.writable?(fn) raise ArgumentError, "#{fn} is not writeable" end elsif !::File.writable?(::File.dirname(fn)) raise ArgumentError, "#{::File.dirname(fn)} is not writable" end true end |