Method: Arrow::Logger::FileOutputter#initialize

Defined in:
lib/arrow/logger/fileoutputter.rb

#initialize(uri, description = DEFAULT_DESCRIPTION, format = DEFAULT_FORMAT) ⇒ FileOutputter

Create a new Arrow::Logger::FileOutputter object. The io argument can be an IO or StringIO object, in which case output is sent to it directly, a String, in which case it is used as the first argument to File.open, or an Integer file descriptor, in which case a new IO object is created which appends to the file handle matching that descriptor.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/arrow/logger/fileoutputter.rb', line 36

def initialize( uri, description=DEFAULT_DESCRIPTION, format=DEFAULT_FORMAT )
	if uri.hierarchical?
		@io = File.open( uri.path, File::WRONLY|File::CREAT )
	else
		case uri.opaque
		when /(std|def)err/i
			@io = $stderr
		when /(std|def)out/i
			@io = $defout
		when /^(\d+)$/
			@io = IO.for_fd( Integer($1), "w" )
		else
			raise "Unrecognized log URI '#{uri}'"
		end
	end

	super
end