From: Robert Klemme Date: 2003-02-27T22:59:50+09:00 Subject: Re: Redirecting/Logging output how about: class SplitOutput def initialize(*ios) @outputs = ios end def print(*args) @outputs.each{ |io| io.print(*args) } end def printf(*args) @outputs.each{ |io| io.printf(*args) } end def puts(*args) @outputs.each{ |io| io.puts(*args) } end def putc(arg) @outputs.each{ |io| io.putc(arg) } end end $logfile = File.new 'log.txt','w' $logger = SplitOutput.new($stdout, $logfile) $logger.printf "test" robert "Michael Bruschkewitz" schrieb im Newsbeitrag news:MPG.18c82611c3c3067b989699@192.168.0.61... > Hello, > the following code solves my problem for now, but is there a "nicer" > solution? > --------------------- SOS -------------------- > $logfile = File.new 'log.txt','w' > def puts (*args) $defout.puts args; $logfile.puts args end > def putc (arg) $defout.putc arg; $logfile.putc arg end > def print(*args) $defout.print args; $logfile.print args end > def printf (format,a1=nil,a2=nil,a3=nil,a4=nil,a5=nil,a6=nil,a7=nil,a8 > =nil) > $defout.printf format, a1,a2,a3,a4,a5,a6,a7,a8 > $logfile.printf format, a1,a2,a3,a4,a5,a6,a7,a8 > end > puts Time.new,1,2,3,4; printf "%02x ",127; print 1,2,3; putc 'a' > -------------------- EOS ------------------------ > > Michael B.