From: Sean O'Halpin Date: 2006-07-28T23:18:12+09:00 Subject: Re: Catching all that goes to $stderr On 7/28/06, Pavel Smerk wrote: > Hello, > > how can I catch all output going to $stderr (e.g. to send some warning > emails time to time in case of daemon etc.)? > > Thanks, > > P. > > Something like this? ioproxy = STDERR.dup def ioproxy.write(*args, &block) p args #STDERR.write(*args, &block) # if you want to pass it on to real STDERR end $stderr = ioproxy puts "hello" $stderr.puts "error!" puts "world" warn "oops!" __END__ hello ["error!"] ["\n"] world ["oops!"] ["\n"] The newlines are because puts prints its args + newline. You could easily filter that in the write method. Regards, Sean