From: Chuck Remes Date: 2008-06-28T04:32:18+09:00 Subject: Re: Is it ellegant to use a global variable to store a Logger object? On Jun 26, 2008, at 3:53 AM, Andrea Fazzi wrote: > Chuck Remes ha scritto: >> >> On a related note, I'm curious how people solve the problem of >> turning logging on and off during runtime. >> >> I hate code like: >> >> logger.log(:debug, "some msg") unless logger.nil? >> >> I usually provide a null class for my loggers which silently >> swallow any messages sent to them if the logging function is >> disabled. It cleans up the code considerably. > > Of course you can do that because you're setting a logger instance > for each object with logging capability. But what to do if you are > using a global logger instance and you wish to turn off logging > selectively? Correct. I haven't had a situation where I needed to do selective logging. I am open to suggestions for elegantly solving this problem. cr