Parent

Methods

Log4r::FileOutputter

Convenience wrapper for File. Additional hash arguments are:

:filename
Name of the file to log to.
:trunc
Truncate the file?

Attributes

trunc[R]

(Not documented)

filename[R]

(Not documented)

Public Class Methods

new(_name, hash={}) click to toggle source

(Not documented)

# File log4r/outputter/fileoutputter.rb, line 16
    def initialize(_name, hash={})
      super(_name, nil, hash)

      @trunc = Log4rTools.decode_bool(hash, :trunc, false)
      _filename = (hash[:filename] or hash['filename'])
      @create = Log4rTools.decode_bool(hash, :create, true)

      if _filename.class != String
        raise TypeError, "Argument 'filename' must be a String", caller
      end

      # file validation
      if FileTest.exist?( _filename )
        if not FileTest.file?( _filename )
          raise StandardError, "'#{_filename}' is not a regular file", caller
        elsif not FileTest.writable?( _filename )
          raise StandardError, "'#{_filename}' is not writable!", caller
        end
      else # ensure directory is writable
        dir = File.dirname( _filename )
        if not FileTest.writable?( dir )
          raise StandardError, "'#{dir}' is not writable!"
        end
      end

      @filename = _filename
      if ( @create == true ) then
        @out = File.new(@filename, (@trunc ? "w" : "a")) 
        Logger.log_internal {
          "FileOutputter '#{@name}' writing to #{@filename}"
        }
      else
        Logger.log_internal {
          "FileOutputter '#{@name}' called with :create == false, #{@filename}"
        }
      end
    end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.