From: Ben Giddings Date: 2003-07-30T09:56:12+09:00 Subject: Re: Warnings? On Tuesday, July 29, 2003, at 07:54 PM, Michael Davis wrote: > I can appreciate the difficulty, however, I would rather not suppress > all warnings and yet I have code that generates warnings that are > okay. Will it be possible to turn off warnings and then turn them > back on again at runtime? This would at least provide me an option to > disable warning messages during methods that generate warnings. When you say you have "code that generates warnings that are ok", you mean the warnings are safe to ignore, or code that generates warnings that looks ok to you? And when you say "turn them back on again at runtime", do you mean a variable you can change programmatically, or a function you can run that determines whether warnings go to the console or not? A typical unix way of dealing with output you don't care about is redirecting it to /dev/null, so you could create methods that reassign $stderr to the default value or /dev/null depending on whether or not you want to see them: def warningsOn $stderr.flush $stderr = STDERR end def warningsOff $stderr.flush $stderr = File.open('/dev/null', 'w') end (thinks _why_ for the prototype) Ben