Convenience wrapper for File. Additional hash arguments are:
Name of the file to log to.
Truncate the file?
# File lib/log4r/outputter/fileoutputter.rb, line 16 16: def initialize(_name, hash={}) 17: super(_name, nil, hash) 18: 19: @trunc = Log4rTools.decode_bool(hash, :trunc, false) 20: _filename = (hash[:filename] or hash['filename']) 21: @create = Log4rTools.decode_bool(hash, :create, true) 22: 23: if _filename.class != String 24: raise TypeError, "Argument 'filename' must be a String", caller 25: end 26: 27: # file validation 28: if FileTest.exist?( _filename ) 29: if not FileTest.file?( _filename ) 30: raise StandardError, "'#{_filename}' is not a regular file", caller 31: elsif not FileTest.writable?( _filename ) 32: raise StandardError, "'#{_filename}' is not writable!", caller 33: end 34: else # ensure directory is writable 35: dir = File.dirname( _filename ) 36: if not FileTest.writable?( dir ) 37: raise StandardError, "'#{dir}' is not writable!" 38: end 39: end 40: 41: @filename = _filename 42: if ( @create == true ) then 43: @out = File.new(@filename, (@trunc ? "wb" : "ab")) 44: Logger.log_internal { 45: "FileOutputter '#{@name}' writing to #{@filename}" 46: } 47: else 48: Logger.log_internal { 49: "FileOutputter '#{@name}' called with :create == false, #{@filename}" 50: } 51: end 52: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.