From: "ara.t.howard" Date: 2008-06-24T09:02:35+09:00 Subject: Re: Is it ellegant to use a global variable to store a Logger object? On Jun 23, 2008, at 2:59 PM, Suraj Kurapati wrote: > ara.t.howard wrote: >> this is a bad idea. try to use rails' code with other code that uses >> ruby's logging class and you'll see what i mean. > > Perhaps they modify ruby's logging class directly? yup. Rails.send('bad!') > I am proposing > something different: a selective injection of logging functionality > into > a library's top-level module. > >> it's better just to keep things simple imho > > I agree, but keep what simple? Implementation or interface? > > Iņaki seems to want the interface to be simple, i.e. an automatic > logging facility that is (1) private to his library and (2) does not > require any explicit enabling (include Logging) or addressing (a LOG > constant). > >> your meta-programming bit will fail, for example, if someone does >> >> module M >> extend AddLoggingToNested >> end > > That is easily solved by aliasing included() to extended(): > > module AddLoggingToNested > # ... code from previous email ... > > class << self > alias extended included > end > end > -- > Posted via http://www.ruby-forum.com/. > yup i understand it all - because i've done it ;-) in the end i just decided it was easier to use a singleton/module level methods - not least of which because grep -R Logger . ends up being used a ton in debugging the logs of a crashed program. anyhow, i'm not disagreeing - just noting that i've done both extensive and tend towards the simple and explicit pattern with logging - YMMV. cheers. a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama